Hi all,
I have a problem regarding use of manualreset events in .net.
I have a developed a sample appliation in which entries from the
listview which I say is a queue for my processes.I want to schedule
these processes in my queue.
I also want to stop the processing by selcting the pause so that the
scheduling stops and again if i say add schedule the schedule should
start again.I have used manual reset events to control the
communication between scheduling. Bcz msdn says we can't have control
on autoreset events.
Remember I have used only one thread which is managing the entire
processing.
The sample code which i have tried is -
Class transferManager
Public Function New()
transferEvent(transferEvent.DATAAVAIL) = New
ManauaResetvent(false)
transferEvent(transferEvent.STOP) = New ManauaResetvent(false)
'pause the transfer
transferEvent(transferEvent.TERMINATE) = New
ManauaResetvent(false)
End Function
Public Function Start(Byval lvw as listview)
tranfermanager = lvw
transferThread.start()
End Function
Public Function Stop()
'check for wheter set event is data avail if yes then
transferEvent(transferEvent.DATAAVAIL).reset()
transferEvent(transferEvent.STOP).set()
'else
transferEvent(transferEvent.STOP).set()
End Function
Public Function DataAvailable()
'check for wheter set event is stop if yes then
transferEvent(transferEvent.STOP).reset()
transferEvent(transferEvent.DATAAVAIL).set()
'else
transferEvent(transferEvent.DATAAVAIL).set()
End Function
Public Function TransferEngine() 'thread proc associated with the
thread
Do while
'if any of the stop or terminate set then return
Do while tranfermanager.items.count <> 0
transfer( tranfermanager.items(0)) 'start process
end while
end while
End Function
Private transferEvent(2) as ManualResetEvent()
Private transferThread as new thread(false)
Private tranfermanager as new listview
End Class
SO my exact problem is i say "add schedule" the process is added and
call to DataAvailable() is given so that the scheduling is started .
But in between if i say stop the schudule is stoopped by calling
Stop(). Now if i again say add shedule call to DataAvailable()
doesn't start the thread again it is in 'stopped' state what could be
the reason. Any ideas.
That means somehow my Threadproc is not executing again after pause
Sample application would also do.
Thanks in advance