private void TradeWindow_Closed(object sender, EventArgs e) { this.Dispatcher.Invoke(DispatcherPriority.Background, (ThreadStart) delegate { tradeWindow = null; }); }
private async Task OpenTradeWindow() { await Task.Run(() => { this.Dispatcher.Invoke(DispatcherPriority.Background, (ThreadStart) delegate { if (tradeWindow == null) { tradeWindow = new TradeWindow(CurrencyPair.Parse(selectedCurrency)); tradeWindow.Owner = MainWindow; tradeWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner; tradeWindow.Show(); tradeWindow.Closed += TradeWindow_Closed; } }); }); }