Click here to Skip to main content
15,922,894 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Here is my code :

C#
private void ShowLoadingWindow()
        {
            frmLoading obj = new frmLoading ();
            obj.Show();
        }
       

        private void button1_Click(object sender, EventArgs e)
        {
            Task t1 = new Task(new Action(ShowLoadingWindow));
            t1.Start();
        }
what i am doing is, i am starting a task when the button is clicked and showing a window form as loading.
The form is shown but the problem is the Loading Form UI is not responding.
Please give me the solution. I dont want to use async keywords as i am using 4.0 framework
Posted
Updated 24-Dec-14 17:49pm
v3
Comments
DamithSL 24-Dec-14 10:16am    

You should not call Sleep from the UI thread. It makes no sense to do that. During the whole delay, the UI thread won't be responding because you tell the UI thread to sleep for 5 seconds.
 
Share this answer
 
Don't do it that way.
Create and display your Loading form, and as part of that forms Shown event start a BackgroundWorker thread to handle the long-term operation(s).
When the thread finishes, you then close the "loading" form.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900