How do I use a thread for example, is I have a block of code that takes 5 seconds to finish executing after clicking the button, and while it is being done, I want to show a loader so the user knows that it is still loading. Can I have an example?
Asked
Active
Viewed 175 times
-1
-
Possible duplicate of [C# Windows Form Application : how to do something in background after the form has been loaded?](https://stackoverflow.com/questions/16985370/c-sharp-windows-form-application-how-to-do-something-in-background-after-the-f) – FCin Nov 30 '18 at 07:44
1 Answers
0
User Wait Curser when you start executing your logic
Cursor.Current = Cursors.WaitCursor;
When you finish change to default
Cursor.Current = Cursors.Default;

Mdyahiya
- 167
- 3
- 15
-
No, not just the cursor. I have a gif ready in a picturebox, I want to show it while the block of code is being executed – Loue Potente Nov 30 '18 at 06:57
-
[https://social.msdn.microsoft.com/Forums/vstudio/en-US/596908bc-fdbb-4905-ba22-baa38dcbdce3/using-a-picturebox-to-display-a-gif-image-showing-an-animated-image-without-the-image-freezing-when] check this link. Hope is this one you are talking about – Mdyahiya Nov 30 '18 at 07:08
-
Here is another link from SO. [https://stackoverflow.com/questions/31315793/how-to-show-an-animated-loading-form-while-executing-code-in-windows-forms-c-sha] – Mdyahiya Nov 30 '18 at 07:14