C# windows form wait




















To make things easier, the event args for the method include a collection of arguments that you can pass in, and a reference to the WaitWindow object so that the message displayed can be updated during the process. The code below shows most of the things you may want to do. For more examples, see the demo project. Next, you need to call the WaitWindow with the method you have created. The example below just uses the default, "Please wait Again, there are more examples in the demo project.

There are two methods exposed by the WaitWindow object that can be called from within the worker method. These are the methods, Cancel and the property, Message. What if it is not framework 4. Then what will be the approach? Sounds like you want a splash screen that is dismissed after 5 seconds.

Eric J. That looks like a lot of code at a quick glance. The other person that posted seems to have a more suited solution but thanks for your post :! Yeah the other solution is very elegant. It is indeed but it turns out it doesn't work, I can still click buttons cries — Zain. You should edit the accepted answer to show what additional steps you needed to make it work. That way, the answer is more useful to the next person with the problem :- — Eric J. Sign up or log in Sign up using Google.

Sign up using Facebook. The Action is a delegate type, which is the same as Func delegate except that the Action delegate does not return a value. In other words, an Action delegate can be used with a method that has a void return type. Adding worker parameter to the frmWaitForm constructor allows you to initalize the Worker property as the following c code. And don't forget to override the OnLoad method allows you to start the new thread when closing the form. In my case there was the need to give visual feedback to the user by flashing a control it is a chart control that can be copied to clipboard, which changes its background for some milliseconds.

It works fine this way:. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Wait one second in running program Ask Question.

Asked 9 years, 8 months ago. Active today. Viewed k times. Red; System. Sleep ; İ want to wait one second before printing my grid cells with this code, but it isn't working. Drenmi 8, 4 4 gold badges 40 40 silver badges 49 49 bronze badges. What code is supposed to be run after the 1 second wait? How do you know it's not working? Try sleep and see if it's working. This works fine: System.

Sleep ; — Andrew. Add a comment. Active Oldest Votes. Is it pausing, but you don't see your red color appear in the cell? Try this: dataGridView1. Red; dataGridView1. Refresh ; System. Sleep ;.



0コメント

  • 1000 / 1000