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

How to access named pipes using JavaScript in Firefox add-on? -

multithreading - OPAL (Open Phone Abstraction Library) Transport not terminated when reattaching thread? -

node.js - req param returns an empty array -