|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Member (7 bit)
Join Date: May 2003
Location: Tranquility
Posts: 112
|
Multithreading VB
Not likely to get many hits with a disgusting title like that.
The problem is I have a function that deadlocks. So, I would like to have a timeout on the function call (if 10 seconds pass, close thread and resume control). The only way I know to do this is by concurrency. I have never done concurrent programming in VB, in fact I only know about 1 month of amateur VB. But, what I am looking for is a simple way to spawn a thread which runs the function while the main thread runs a timer which will close said thread when the timer calls back if it has not already terminated. So, is there a "Multithreading VB for Dummies" or a "Multithreading VB for Retards" which might be closer to my level? |
|
|
|
|
|
#2 |
|
Professional gadfly
|
Which version of VB are you using?
|
|
|
|
|
|
#3 |
|
Member (7 bit)
Join Date: May 2003
Location: Tranquility
Posts: 112
|
6
Yeah, I know, concurrency is absolutely abysmal in VB6. But, I am using the VBRAPI and the CeRapiInit function does not return until it connects. So, I spawn two threads. The first kicks off a timer and the second calls CeRapiInit. If the timer thread calls back, then it spawns a third thread which calls CeRapiUninit. Well, it kinda works in the IDE. It blocks and then unblocks after the timer triggers. But, when the application ends, it deadlocks like something is still hanging. When run from a standalone exe, it gives me an illegal read because either I did something wrong or because VB can't even declare its own pointers properly. If you want, I can post some of my code for review. |
|
|
|
|
|
#4 |
|
Professional gadfly
|
Yes, VB6 is not very helpful when it comes to doing this kind of thing.
Although I am not familiar with RAPI, it sounds like you are doing about what I would try in this situation. Posting the code would probably help. |
|
|
|
|
|
#5 |
|
Member (7 bit)
Join Date: May 2003
Location: Tranquility
Posts: 112
|
Is concurrency supported in VB .Net?
Would moving to the new version be better? Attached is the relevant code. If you want to run it, you must get the VBRAPI which can be found here and then add it as a new reference. Thanks for your time. |
|
|
|
|
|
#6 |
|
Professional gadfly
|
I have been looking at RAPI documention, and it says that CeRapiInitEx is a better function to use because it returns immediately, but you have to check for proper initilization. Have you tried this method?
VB.NET is far better when it comes to multithreading. I haven't done too much with it year (working more on C# right now), but you don't have to use any API calls for mutlithreading in VB.NET; it is integrated much better. |
|
|
|
|
|
#7 |
|
Member (7 bit)
Join Date: May 2003
Location: Tranquility
Posts: 112
|
Well, the CeRapiInitEx function has this little caveat which says "Avoid this function". I figured the author must know what he is talking about, so I avoided it. I have tried it, but to no avail.
I figured a simple tiny 3 thread program would be less of a hassle than using CeRapiInitEx, which requires checking handles, waiting for objects, raising events, etc. I think I will cough up the $5 and get the trial version of Visual Studio Dot Net. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|