multithreading - How do you make the application wait and keep other processes running at the same time in C#? -
using system.threading.thread.sleep( ) makes entire application stop time taken in arguments. want other processes running while 1 process waiting particular amount of time. put in short, want way other system.threading.thread.sleep( ) in application not stop entire thing.
example: if have label changes text every 5 seconds, should able press button can other process, changing image.
thread.sleep()
puts current thread sleep. if ui thread, might block application , looks blocked. background threads still running.
if want sleep without blocking, use following code:
await task.delay(5000); // continue here code, such updating label
this doesn't block ui thread, delays proceeding of function. have declare method async
Comments
Post a Comment