private void LogException(Exception e, LogsTypes typeOfError) { Trace.WriteLine( String.Format(@"Error on thread loop of thread {0} instance {1} " + e, Name, RoleEnvironment.CurrentRoleInstance), EnumUtils.AsString(typeOfError)); }
private static void Watching(Thread[] threads) { // TODO : surveiller pour de vrai // can use ShouldStop Trace.WriteLine("I'm watching U ! You are " + ((threads.Length != 1) ? threads.Length.ToString(CultureInfo.InvariantCulture) : "Lonely ") + " !!" , EnumUtils.AsString(LogsTypes.Supervision)); // 2h Thread.Sleep(2 * 60 * 60 * 1000); }
public override void Run() { try { try { BusinessProcessLibrary.Configuration.DownloadGdal(); BusinessProcessLibrary.Configuration.ConfGdal(); } catch (Exception e) { Trace.WriteLine("Erreur critique: Fail to Download Gdal ?\n WorkerRole:" + e, EnumUtils.AsString(LogsTypes.DevError)); return; } // On lance les Threads de travail, ... int threadNumber; string threadNumberString = RoleEnvironment.GetConfigurationSettingValue("ThreadNumber"); if (!int.TryParse(threadNumberString, NumberStyles.Integer, CultureInfo.InvariantCulture, out threadNumber)) { Trace.WriteLine("Fail to find the number of thread, fail to convert ThreadNumber: \"" + threadNumberString + "\"", EnumUtils.AsString(LogsTypes.DevError)); KillDeployment(); } Thread[] threads = StartThreads(threadNumber); // puis on commence à les surveiller. while (true) { try { Watching(threads); } catch (Exception e) { Trace.WriteLine("I'm ill, look that " + e, EnumUtils.AsString(LogsTypes.Supervision)); } } } catch (Exception e) { Trace.WriteLine("Erreur critique: WorkerRole:" + e, EnumUtils.AsString(LogsTypes.DevError)); } //function (have to) never return ! }
protected virtual void Sleep() { CustomSleeper.Increment(); Trace.WriteLine("Thread " + Name + ", no more message, sleep " + CustomSleeper.TimeToSleep + "s", EnumUtils.AsString(LogsTypes.Verbatile)); CustomSleeper.Sleep(); }
private void KillDeployment() { Trace.WriteLine("This deployment (" + RoleEnvironment.DeploymentId + ") will be kill.", EnumUtils.AsString(LogsTypes.Information)); // TODO : implement this throw new NotImplementedException(); }