private void Upd_Finished(object sender, EventArgs e) { YTDLInteract.UpdateYAYD upd = (YTDLInteract.UpdateYAYD)sender; // get the UpdateYAYD instance as UpdateYAYD, not as object jts.AppendOutput("Finished. Status reported: " + upd.Status); jts.AppendOutput("Do note that the status is not trustworthy!"); upd.TrimmedErrorDataReceived -= Upd_TrimmedErrorDataReceived; // disconnect the events to let the UpdateYAYD instance die upd.TrimmedOutputDataReceived -= Upd_TrimmedOutputDataReceived; upd.Finished -= Upd_Finished; }
// Menu: update youtube-dl private void MenuItem_Click_1(object sender, RoutedEventArgs e) //raised when clicked Update youtube-dl in menu { YTDLInteract.UpdateYAYD upd = new YTDLInteract.UpdateYAYD(); // create new instance jts = new AuxWindows.JointTextShow(); // create new console window upd.TrimmedErrorDataReceived += Upd_TrimmedErrorDataReceived; // send output to console upd.TrimmedOutputDataReceived += Upd_TrimmedOutputDataReceived; // send error to console upd.Finished += Upd_Finished; // cleanup after finishing with the command jts.Show(); // show the console window upd.Ready(); upd.Start(); // start the update }