Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

There is an On Error, is there an On Event???? 1

Status
Not open for further replies.

Japskunk72

Programmer
Feb 19, 2003
64
US
I have a function that watches harddrive changes and it often stalls waiting for a harddrive change, if there is no change i want to kill the function and re run it so it doenst keep hanging the system. Im looking for an on event (like when a counter counts so high or when a timer times out). Right now the Function just hangs untill a file is written. is there something to solve my problem?
Thanks
JT
 
What do you mean? How would i use the timer control to break a function? My function does have a loop, and i know how to break the loop and leave the function. but it hangs when it is waiting for a directory change. how would i break an event?
 
I assume that you are actually using code based on my example in thread222-576673

This is a blocking, synchronous operation, in that it will wait - as you have discovered - until a change occurs. You either need to spawn the call in a new thread (my example code on this technique is in thread222-519374), or use the asynchronous version and then either poll the result of GetQueuedCompletionStatus or wait on a completion port using WaitForSingleObjectEx with a timeout applied
 
Erm..alternatively make it into a class, and put it into an ActiveX DLL that can raise an event
 
Thanks Strongm,
So i could put it in a DLL, Use a public variable to let me know when it is watching and when it isnt? how do i kill the process of the function or the DLL if i think it has been waiting too long?
 
Ok Thanks again Stronm,
I was reading backwords or something, I got what you are saying. I thought you ment instead of using GetQueuedCompletionStatus, you could use a ActiveX to raise the even.

So thanks alot!! That was exactly what i was looking for
JT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top