NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 60 61 62 63 64 … 93 Next »
Threads in Plugins

 
  • 0 Vote(s) - 0 Average
Threads in Plugins
Old Dog
Offline

Posting Freak

Posts: 1,083
Threads: 99
Joined: Jul 2005
#1
2005-12-31, 11:16 PM
I have a thread running in my plugin. After Exiting GBPVR normally, the next time I invoke GBPVR it simply will not start. I have localized the problem to this thread, which BTW is waiting on an event.

I have tried alot of things to terminate the thread in the destructor for it's class to no avail.

Is anyone else using threads in their plugins? Anyone have any experience with this kind of problem?

Thanks in Advance,
David
Learning new tricks!
Visit Plain Jane's Collection
Hunter Sun
Offline

Junior Member

Posts: 32
Threads: 10
Joined: Jun 2005
#2
2005-12-31, 11:38 PM
On the Deactivate method of the plugin, have you tried running a thread abort?

- Scott
Old Dog
Offline

Posting Freak

Posts: 1,083
Threads: 99
Joined: Jul 2005
#3
2006-01-01, 02:06 AM
Hunter Sun Wrote:On the Deactivate method of the plugin, have you tried running a thread abort?

- Scott
My (mis?)understanding is that deactivate is when control returns to the main menu but the application is still running. If so, I don't want the tread aborted at this time, only when the apllication terminates.

Thanks,
David
Learning new tricks!
Visit Plain Jane's Collection
Old Dog
Offline

Posting Freak

Posts: 1,083
Threads: 99
Joined: Jul 2005
#4
2006-01-01, 06:29 AM
Old Dog Wrote:I have a thread running in my plugin. After Exiting GBPVR normally, the next time I invoke GBPVR it simply will not start. I have localized the problem to this thread, which BTW is waiting on an event.

I have tried alot of things to terminate the thread in the destructor for it's class to no avail.

Is anyone else using threads in their plugins? Anyone have any experience with this kind of problem?

Thanks in Advance,
David

Solved the problem by creating an Application.OnExit event handler that terminates the thread.
Learning new tricks!
Visit Plain Jane's Collection
glensh
Offline

Junior Member

Posts: 41
Threads: 9
Joined: Sep 2005
#5
2006-02-01, 04:05 AM
Hi David,

Could you give the code you put in to solve this?
I put the following into my plugins constructor...

Application.ApplicationExit += new EventHandler(OnExit);

and then the following method...

protected void OnExit (object sender, System.EventArgs args) {
CommonGBPVRUtilities.StatusLog.LogMessage("Plugin.log","Application is exiting!");
}

But I didn't get a log entry, so I don't think it is working.

Question 2: Does your solution work on the MVP? ie: does the application exit event occur when the MVP is turned off?

Thanks in advance.

Glen
Athlon 3000, 1 GB, WinXP, PVR-150, 2 x MVP
Old Dog
Offline

Posting Freak

Posts: 1,083
Threads: 99
Joined: Jul 2005
#6
2006-02-01, 11:50 AM (This post was last modified: 2006-02-01, 12:03 PM by Old Dog.)
Code:
...
[SIZE="3"]
    WThread = new Thread(new ThreadStart(WaitThread));
    WThread.Start();
    Application.ApplicationExit += new EventHandler(this.OnExit);
}

//----------------------------------------------------------------------
// OnExit - Application exit event handler
//----------------------------------------------------------------------
private void OnExit(object sender, EventArgs e)
{
    Logger.Verbose("Appearance: Exit event.");
    TerminateThread = true;
    WThread.Join();
}

//----------------------------------------------------------------------
// WaitThread - Thread that reloads the application when signaled from
// any instance of GBPVR.exe
//----------------------------------------------------------------------
private void WaitThread()
{
    Thread.Sleep(2000);    // prevents restarting more than once.
    WThread.Priority = ThreadPriority.AboveNormal;
    while (!TerminateThread)
    {


[/SIZE]

where would this
Code:
CommonGBPVRUtilities.StatusLog.LogMessage(...
log a message?
Learning new tricks!
Visit Plain Jane's Collection
glensh
Offline

Junior Member

Posts: 41
Threads: 9
Joined: Sep 2005
#7
2006-02-01, 09:25 PM
CommonGBPVRUtilities.StatusLog.LogMessage("Plugin.log","Application is exiting!");

This logs to the gbpvr directory in a file based on your first parm.

Possibly the utilities logging services are already stopped by the time the application exit event is handled.

Thanks for the code snippet.

Glen
Athlon 3000, 1 GB, WinXP, PVR-150, 2 x MVP
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  Plugins and NPVR. Where do we start? sub 80 68,063 2020-11-26, 10:02 PM
Last Post: mandai
  I want to start developing plugins...but how? OrenShapir 6 3,990 2014-11-18, 10:38 PM
Last Post: mvallevand
  Tuner plugins and client id mvallevand 2 2,040 2013-07-03, 01:39 AM
Last Post: mvallevand
  Tuner Plugins - Output folders mvallevand 2 2,031 2013-02-19, 07:45 PM
Last Post: mvallevand
  .NET 4 plugins? McBainUK 20 7,667 2012-12-11, 08:48 PM
Last Post: sub
  Integrated Development Environment (IDE) for plugins osx-addict 5 2,713 2012-10-18, 08:35 PM
Last Post: osx-addict
  Tuner plugins mvallevand 4 2,419 2012-08-05, 11:19 PM
Last Post: mvallevand
  Recorder plugins - Deleting tuners mvallevand 1 1,492 2012-03-29, 12:51 AM
Last Post: sub
  Recorder plugins - scheduling mvallevand 4 2,346 2012-03-26, 05:09 PM
Last Post: mvallevand
  Client - Tuner plugins mvallevand 53 13,407 2011-09-17, 07:19 PM
Last Post: mvallevand

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode