Shoutbox

Thread or Window - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Forum: Plug-Ins (/forumdisplay.php?fid=28)
+------ Thread: Thread or Window (/showthread.php?tid=28419)

Thread or Window by CMI on 07-09-2004 at 11:05 PM

Is there any way to get a seperate thread or window running from inside a plug in? I'm getting nothing but crashes and errors. It seems the only way to get plug-in to execute code is when MP! calls events. I'd like to get around that.


RE: Thread or Window by Mnjul on 07-10-2004 at 03:03 AM

There could be security issues; and Plus! doesn't accept many functino calls whose caller isn't in the same thread as plugin's initialize function. Well, sort of, it may be the plugin developer who should solve this problem ;)


RE: RE: Thread or Window by CMI on 07-10-2004 at 03:40 AM

quote:
Originally posted by Mnjul
There could be security issues; and Plus! doesn't accept many functino calls whose caller isn't in the same thread as plugin's initialize function. Well, sort of, it may be the plugin developer who should solve this problem ;)


So that's a "no"?

I don't really see how creating a thread is a security issue... I wouldn't be talking to Plus! anyway. I'd be perfectly happy using the IMessenger interface. This seems to be my only option because I certianly didn't see a timer function for plug-ins in Plus!, which would be nice.
RE: Thread or Window by Mnjul on 07-10-2004 at 03:43 AM

What kind of timer function do you need? :)


RE: RE: Thread or Window by CMI on 07-10-2004 at 04:15 AM

quote:
Originally posted by Mnjul
What kind of timer function do you need? :)


I just need a function inside a plug-in that can either use IMessenger or talk to Plus! and will be triggered predictably at least every couple of seconds.
RE: Thread or Window by Mnjul on 07-10-2004 at 04:59 AM

You can set IMessenger as a global variable and use SetTimer in Initialize, and set up a TimerProc call back function, I think...


RE: RE: Thread or Window by CMI on 07-10-2004 at 05:51 AM

quote:
Originally posted by Mnjul
You can set IMessenger as a global variable and use SetTimer in Initialize, and set up a TimerProc call back function, I think...


I thought about that but for some reason I didn't think it would work. I guess I'll give it a shot, since I can't think of a good reason it wouldn't work.
RE: Thread or Window by Mnjul on 07-10-2004 at 07:12 AM

Well, perhaps you may give it a try and if it doesn't really work, we can have further discussion ;)


RE: Thread or Window by Mike on 07-10-2004 at 07:18 AM

Also in what programing language are you gonna do it?
Because if it is in VB then i have an example to show you how to use the SetTimer api ;)


RE: Thread or Window by Millenium_edition on 07-10-2004 at 08:35 AM

what you can do is reference the MessengerAPI
the use

code:
Private WithEvents objMessenger As MessengerAPI
Then in the initialize function
code:
Set objMessenger = <insert object name here>
Replace <insert object name here> with the Messenger object Initialize provides.

Also, you can use Class_Initialize and Class_Terminate to show/hide your forms (in vb) and there you can do what you want :)
RE: Thread or Window by CMI on 07-10-2004 at 04:04 PM

Well, SetTimer mostly works. If I'm not really careful it brings down Messenger Plus and concequently MSN Messenger. Of course, now I can't get actions to properly fire using the IMessenger interface. Man I hate Visual Basic.


RE: Thread or Window by Mnjul on 07-10-2004 at 04:10 PM

You hate VB? Well, great, I code in C++:P

You have to use QueryInterface to get IMessenger and set it to a global variable (so that your call back function can use it) in Initialize function, like

IMessenger* MsgrInstance;

iMessengerObj->QueryInterface(IID_IMessenger,(void**)&MsgrInstance);


RE: Thread or Window by CMI on 07-10-2004 at 04:15 PM

Well, this plug-in is to support a fairly large behind schedule VC++ app. I'm using VB to get things done faster. Of course, I'm still having the problem where a video invite won't fire :) If anyone is curious, http://www.msnfanatic.com/forums/index.php?showtopic=9888&st=0&


RE: Thread or Window by RaceProUK on 07-11-2004 at 02:54 PM

Mnjul, you don't have to QueryInterface, a mere typecast to IMessenger3* will do the trick (not pretty though I admit).

CMI, if you want to fire off a new thread in C++, just use the following function call:

code:
_beginthread(<funcname>, <stacksize>, <arglist>);
I've only used it with a function that takes a single argument, so I'm not sure how it would handle multiple arguments, but a quick search on MSDN should help. My guess is that you'd have to do a little bit of processing yourself: others on the forums may be able to help you more.
Also, remember to #include <process.h>, or it won't compile.
Don't worry about ending the thread: once the function returns, the thread is terminated by Windows.
RE: Thread or Window by RaceProUK on 07-11-2004 at 05:04 PM

Just because its Win32, doesn't mean you have to use its API. I prefer writing non-platform specific code if I can.


RE: RE: Thread or Window by CMI on 07-11-2004 at 07:07 PM

quote:
Originally posted by raceprouk
Just because its Win32, doesn't mean you have to use its API. I prefer writing non-platform specific code if I can.


I wrote the plug-in in VB, so there is no point trying to use platform independant APIs :) The SetTimer call is working just fine, but I'm still having that StartVideo problem no one seems to know anything about.
RE: Thread or Window by RaceProUK on 07-11-2004 at 08:05 PM

CMI:
I didn't realise you were using VB, as you mentioned the IMessenger interface, which is C++. Reading back over the thread, I see that you are indeed using VB, so anything I gave you for C++ doesn't actually apply. O well, still could be useful.

TB:
I stand by my original comment. Anyway, which uses less resources: standard library function, or Win32 API?


RE: Thread or Window by CMI on 07-11-2004 at 08:06 PM

How about we forget about all this and head over to me StartVideo thread :)


RE: Thread or Window by RaceProUK on 07-11-2004 at 08:11 PM

Good idea.

offtopic: Admins, would a split be useful here?


RE: Thread or Window by RaceProUK on 07-11-2004 at 08:26 PM

Do you know for certain though? I know I don't. Why not run a little test, say create 1000 threads using each method and measuring the resource usage some way.


RE: Thread or Window by RaceProUK on 07-11-2004 at 08:45 PM

Intriguing...