Click here to Skip to main content
15,900,589 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So, what im asking is that when i open an app my button is disabled for long as the app hasnt created the txt. File in the background.

What I have tried:

Something like
Button.disabled=true until file. Exist. Im assuming it could work with while loop but i dont know how to make it
Posted
Updated 13-Mar-20 20:57pm
Comments
codejet 13-Mar-20 19:41pm    
Winforms or what?
[no name] 13-Mar-20 20:14pm    
The background should notify the ui.

1 solution

Do your file creation code in a separate thread: the BackgroundWorker Class (System.ComponentModel) | Microsoft Docs[^] is easy to use and provides a "Worker completed" event you can handle to tell you when it is finished.
Set the button.Enabled to false in the designer, then in the BackgroundWorker.RunWorkerCompleted Event (System.ComponentModel) | Microsoft Docs[^] set it to true.
 
Share this answer
 
Comments
Maciej Los 14-Mar-20 6:12am    
5ed!

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