multithreading - Is there a way to pause a thread indefinitely in VB.Net -


i came know thread.suspend not way pause thread indefinitely. please let me know if other way achieve same.

thanks in advance.

a short vb example

private sub form1_shown(sender object, e eventargs) handles me.shown     thrd.isbackground = true     thrd.start() end sub  dim thrd new threading.thread(addressof somethread)  private sub button1_click(sender object, e eventargs) handles button1.click     'pause , resume     'first click pauses, second click resumes     reqpause.set() 'set event end sub  dim reqpause new threading.autoresetevent(false)  private sub somethread()             'simulate work - code here         threading.thread.sleep(500)         debug.writeline(datetime.now.tolongtimestring)         'end simulate work          if reqpause.waitone(0) 'pause requested?             debug.writeline("t-thrd paused")             reqpause.waitone() 'wait here continuation             debug.writeline("t-continue thrd")         end if     loop end sub 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -