What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » multithreaded dll

multithreaded dll
Author: Message:
cooldude_i06
Full Member
***

Avatar
I'm so cool I worry myself.

Posts: 272
Reputation: 9
– / Male / –
Joined: Sep 2003
O.P. multithreaded dll
I need to use a C++ Dll in my script using Interop.Call, however the function this Dll contains runs an infinite loop in the background, which ofcourse freezes WLM because the function does not return anything. I know that VB6 does not support multithreading so calling it through an ActiveX dll won't help. So I'm looking for suggestions.

If I wanted to run this dll in a new thread how would I do that? Can I run a specific function inside the C++ Dll in a new thread? If so how?

Thanks
CD

This post was edited on 06-07-2007 at 03:04 PM by cooldude_i06.
[Image: clb2.jpg]
06-07-2007 03:04 PM
Profile E-Mail PM Web Find Quote Report
Volv
Skinning Contest Winner
*****

Avatar

Posts: 1233
Reputation: 31
35 / Male / Flag
Joined: Oct 2004
RE: multithreaded dll
You could create a timer in MsgPlus to call the function every X milliseconds instead of using an infinite loop.
06-07-2007 03:26 PM
Profile PM Find Quote Report
cooldude_i06
Full Member
***

Avatar
I'm so cool I worry myself.

Posts: 272
Reputation: 9
– / Male / –
Joined: Sep 2003
O.P. RE: multithreaded dll
No the infinite loop is part of the C++ dll and that cannot be changed due to functionality reasons. The only thing I can do is run it in a separate thread so the main function does not wait for it to end and returns a value so that Plus can get going with the script.
[Image: clb2.jpg]
06-07-2007 03:29 PM
Profile E-Mail PM Web Find Quote Report
Mnjul
forum super mod
******

Avatar
plz wub me

Posts: 5396
Reputation: 58
– / Other / Flag
Joined: Nov 2002
Status: Away
RE: multithreaded dll
You can call CreateThread, or alternatively, _bginthread if you're using Visual C++, in your C++ DLL.

But note: any cross-thread reference to the scripting objects will become invalid.

This post was edited on 06-07-2007 at 04:19 PM by Mnjul.
06-07-2007 04:19 PM
Profile PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: multithreaded dll
Multithreading is somewhat possible in VB though (for example with ActiveX, but it depends on what you exactly want to do... (Though doing it in C++ would be easier)

Anyways, out of curiosity, can I ask why the DLL needs an infinite loop? Because in most cases you could always develop a method without inifinate loops (infinite loops are to be avoided as much as possible). So the solution might not be to find a way to make your DLL multithreaded to run an infinite loop, but to improve the code so it doesn't need an infinite loop to start with.

;)

This post was edited on 06-08-2007 at 12:59 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
06-07-2007 09:51 PM
Profile PM Find Quote Report
cooldude_i06
Full Member
***

Avatar
I'm so cool I worry myself.

Posts: 272
Reputation: 9
– / Male / –
Joined: Sep 2003
O.P. RE: multithreaded dll
Well I'm trying to use the Winpcap library, and as far as I have seen the only way to retrieve packetcapture events is using a loop.

The multithreaded problem has been fixed by the use of CreateThread api, thanks.
[Image: clb2.jpg]
06-08-2007 01:42 AM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On