Call function after a period of time in C# -


i have c# code call function like:

private void cmdcommand_click(object sender, eventargs e)     {        m_socclient.close();     } 

but want m_socclient.close(); function called after maybe 30 second. possible?

yes, using async / await feature:

private async void cmdcommand_click(object sender, eventargs e) {      await task.delay(30000);     m_socclient.close(); } 

you can using thread.sleep block ui thread , window won't responsive until task finished.


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -