-> Hier kostenlos registrieren
Hallo,
ich habe gerade ein C# Verständnissproblem:
//----------------------------------------------------------------------
// Zyklisch laufend
private void Btn_start_zykl_Click(object sender, RoutedEventArgs e)
{
// Create a timer with a ms interval.
aTimer = new System.Timers.Timer(2000);
// Hook up the Elapsed event for the timer.
aTimer.Elapsed += OnTimedEvent;
aTimer.AutoReset = true;
aTimer.Enabled = true;
status.Background = new SolidColorBrush(Colors.Green); ->>> funktioniert
}
private void Btn_stop_zykl_Click(object sender, RoutedEventArgs e)
{
aTimer.Stop();
status.Background = new SolidColorBrush(Colors.Red); ->>> funktioniert
}
private void Ablauf()
{
;
// Kommunikationsablauf (entfernt für Test)
}
//
private void OnTimedEvent(Object source, ElapsedEventArgs e)
{
if (!client.Connected)
{
aTimer.Stop(); ->>> funktioniert -> stoppt den Zyklus
MessageBox.Show("Pleace Connect PLC"); ->>> funktioniert -> meldet genau einmal - das die PLC nicht erreichbar
status.Background = new SolidColorBrush(Colors.Red); ->>> funktioniert # NICHT # Wieso???
// anhalten Zyklus bei Komm Verlust
}
else
{
Ablauf();
}
}//Ende Zyklus
//----------------------------------------------------------------------
Ja, wenn das jemand erklären kann, wäre schon interessant.
Vielen Dank!
Das ganze soll einfach in grün und rot den aktuellen Status darstellen.
ich habe gerade ein C# Verständnissproblem:
//----------------------------------------------------------------------
// Zyklisch laufend
private void Btn_start_zykl_Click(object sender, RoutedEventArgs e)
{
// Create a timer with a ms interval.
aTimer = new System.Timers.Timer(2000);
// Hook up the Elapsed event for the timer.
aTimer.Elapsed += OnTimedEvent;
aTimer.AutoReset = true;
aTimer.Enabled = true;
status.Background = new SolidColorBrush(Colors.Green); ->>> funktioniert
}
private void Btn_stop_zykl_Click(object sender, RoutedEventArgs e)
{
aTimer.Stop();
status.Background = new SolidColorBrush(Colors.Red); ->>> funktioniert
}
private void Ablauf()
{
;
// Kommunikationsablauf (entfernt für Test)
}
//
private void OnTimedEvent(Object source, ElapsedEventArgs e)
{
if (!client.Connected)
{
aTimer.Stop(); ->>> funktioniert -> stoppt den Zyklus
MessageBox.Show("Pleace Connect PLC"); ->>> funktioniert -> meldet genau einmal - das die PLC nicht erreichbar
status.Background = new SolidColorBrush(Colors.Red); ->>> funktioniert # NICHT # Wieso???
// anhalten Zyklus bei Komm Verlust
}
else
{
Ablauf();
}
}//Ende Zyklus
//----------------------------------------------------------------------
Ja, wenn das jemand erklären kann, wäre schon interessant.
Vielen Dank!
Das ganze soll einfach in grün und rot den aktuellen Status darstellen.