private void OnTimedEvent(object sender, ElapsedEventArgs e) { ConfigurationTimer timer = (ConfigurationTimer)sender; lock (this.awaitingResponses) { ConfigQuery query; if (this.awaitingResponses.TryGetValue(timer.Request.QueryId, out query)) { this.awaitingResponses.Remove(timer.Request.QueryId); query.Callbacks.OnTimeout(); } } }
public void Close() { this.parser.HandleMessage -= this.HandleEvent; lock (this.awaitingResponses) { foreach (KeyValuePair <string, ConfigQuery> entry in this.awaitingResponses) { ConfigurationTimer timer = entry.Value.Timer; timer.Stop(); } this.awaitingResponses.Clear(); } this.sender.Close(); }
static void Main() { // Logging mit SmartInspect vorbereiten #if DEBUG SiAuto.Si.LoadConfiguration(debugConfigurationFileName); var timer = new ConfigurationTimer(SiAuto.Si, debugConfigurationFileName, 60000); #else SiAuto.Si.LoadConfiguration(releaseConfigurationFileName); var timer = new ConfigurationTimer(SiAuto.Si, releaseConfigurationFileName, 60000); #endif // Das eigentliche Ausführen der Anwendung SiAuto.Main.EnterProcess("ProjektSimulation"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); SiAuto.Main.LeaveProcess("ProjektSimulation"); // Sicherstellen, dass alle Nachrichten aus dem Backlog per Tcp geschrieben werden SiAuto.Main.LogError("Flush Backlog!"); // Logging Komponente beenden. SiAuto.Si.Dispose(); }
public void SendConfiguration(ConfigurationParams parameters, string queryId, IConfigurationCallback callbacks, double timeoutMs) { if (parameters == null) { throw new ArgumentNullException("parameters"); } if (callbacks == null) { throw new ArgumentNullException("callbacks"); } if (timeoutMs <= 0) { throw new ArgumentException("timeout"); } if (string.IsNullOrEmpty(queryId)) { throw new ArgumentException("queryId"); } ConfigurationRequest request = new ConfigurationRequest(parameters, queryId); ConfigurationTimer timer = new ConfigurationTimer(timeoutMs, request); ConfigQuery query = new ConfigQuery(request, callbacks, timer); lock (this.awaitingResponses) { this.awaitingResponses.Add(queryId, query); timer.AutoReset = false; timer.Elapsed += new ElapsedEventHandler(this.OnTimedEvent); timer.Start(); } this.sender.SendMessage(this.serializer.Serialize(request)); }
internal ConfigQuery(ConfigurationRequest request, IConfigurationCallback callbacks, ConfigurationTimer timer) { this.Request = request; this.Callbacks = callbacks; this.Timer = timer; }