Wiki Link: [discussion:5445]
Static Variable in Pluggins 

Oct 26 2012 at 11:09 AM
Edited Oct 26 2012 at 11:11 AM
Hi all,

I´m writting a pluggin and I´m facing a strange problem.
I need to check a WebService every five minutes so I created a Thread in my pluggin that would check the WebService. The problem is that the Thread in being created for every window and tab that is opened.
I thought I could use a static variable to control this but it does not seem to be working.

I´ve got the SamplePluggin and write my code over it.

The basic idea I had was:

public class SamplePlugin : SpicIE.Host
/// <summary>
/// These two constants define the CLSID and name for the plugin.
/// This must be unique otherwise you won't be able to control, install or deinstall your plugin
/// When developing choose a static unique GUID and leave it as it is
/// </summary>
public const string PLUGIN_GUID = "20D33922-37D5-456E-915E-D87AE53106C6";
public const string PLUGIN_PROGID = "DotzPluggin";

public static SamplePlugin HostInstance = null;
private static string test = null;

public SamplePlugin() : base()
if (SamplePlugin.test == null)
Host.TraceSink.TraceEvent(TraceEventType.Information, 145, "Thread created");
SamplePlugin.test = "created";

//Create my WebService thread here

The problem is I can see in DebugView that the variable test is always null for new tabs and new Windows even though it is declared as static. It seems that a different version of my class is being created for every new tab and window.

Is there another way I can achieve this?

Thank you

Page view tracker