Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 07-15-2003, 03:31 PM   #1
Member (7 bit)
 
Dreamscape's Avatar
 
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?
Dreamscape is offline   Reply With Quote
Old 07-16-2003, 11:01 AM   #2
Professional gadfly
 
doctorgonzo's Avatar
 
Join Date: Jan 2002
Location: Minneapolis, MN
Posts: 6,364
Send a message via MSN to doctorgonzo
Which version of VB are you using?
doctorgonzo is offline   Reply With Quote
Old 07-17-2003, 08:12 AM   #3
Member (7 bit)
 
Dreamscape's Avatar
 
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.
Dreamscape is offline   Reply With Quote
Old 07-17-2003, 08:42 AM   #4
Professional gadfly
 
doctorgonzo's Avatar
 
Join Date: Jan 2002
Location: Minneapolis, MN
Posts: 6,364
Send a message via MSN to doctorgonzo
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.
doctorgonzo is offline   Reply With Quote
Old 07-17-2003, 09:16 AM   #5
Member (7 bit)
 
Dreamscape's Avatar
 
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.
Attached Files
File Type: zip concurrency.zip (2.2 KB, 43 views)
Dreamscape is offline   Reply With Quote
Old 07-17-2003, 10:35 AM   #6
Professional gadfly
 
doctorgonzo's Avatar
 
Join Date: Jan 2002
Location: Minneapolis, MN
Posts: 6,364
Send a message via MSN to doctorgonzo
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.
doctorgonzo is offline   Reply With Quote
Old 07-17-2003, 11:29 AM   #7
Member (7 bit)
 
Dreamscape's Avatar
 
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.
Dreamscape is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 08:03 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2