Created
December 3, 2015 06:03
-
-
Save joshmarinacci/942b3e7022a682e92894 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override void OnStart(string[] args) | |
{ | |
string[] imagePathArgs = Environment.GetCommandLineArgs(); | |
if (imagePathArgs.Length >= 2) | |
{ | |
int value = 0; | |
if (Int32.TryParse(imagePathArgs[1], out value)) MaxCPUUsage = value; | |
else | |
{ | |
eventLog.WriteEntry("Fail to convert parameter 1:" + imagePathArgs[1]); | |
} | |
} | |
if (imagePathArgs.Length >= 3) | |
{ | |
int value = 0; | |
if (Int32.TryParse(imagePathArgs[2], out value)) MinRAMAvailable = value; | |
else | |
{ | |
eventLog.WriteEntry("Fail to convert parameter 2:" + imagePathArgs[2]); | |
} | |
} | |
if (imagePathArgs.Length >= 3) | |
{ | |
int value = 0; | |
if (Int32.TryParse(imagePathArgs[3], out value)) Period = value; | |
else | |
{ | |
eventLog.WriteEntry("Fail to convert parameter 3:" + imagePathArgs[3]); | |
} | |
} | |
eventLog.WriteEntry("MaxCPUUsage=" + MaxCPUUsage.ToString() + ", " + "MinRAMAvailable=" + MinRAMAvailable.ToString() + ", " + "Period=" + Period.ToString()); | |
try | |
{ | |
eventLog.WriteEntry("Subscribe channel " + channel); | |
mrePubNub = new ManualResetEvent(false); | |
pubnub.Subscribe<string>(channel, ReceivedMessageCallbackWhenSubscribed, SubscribeMethodForConnectCallback, ErrorCallback); | |
mrePubNub.WaitOne(manualResetEventsWaitTimeout); | |
eventLog.WriteEntry("Channel " + channel + " subscribed."); | |
trf = new Thread(new ThreadStart(Process)); | |
trf.IsBackground = true; | |
trf.SetApartmentState(ApartmentState.MTA); | |
trf.Start(); | |
} | |
catch (Exception erro) | |
{ | |
eventLog.WriteEntry("Subscribe channel " + channel + "\r\n" + erro.Message); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment