I have something that need to be written to the screen AFTER the main window is showing up. But the reality is that the Loaded event code is fully excuted and only then the window is up. What I need to do to change it?
*I dont care to use any other event but "Loaded".
public partial class MainWindow : Window
{
public const string UpdatedClientComputerURL = @"net.tcp://localhost:8181/";
public const string UpdatedClientComputerHostName = "Client1";
public MainWindow()
{
InitializeComponent();
ClientAdministration.ConnectedToServerEvent += ClientAdministration_ConnectedToServerEvent;
ClientAdministration.RestoredDownloadsEvent += ClientAdministration_RestoredDownloadsEvent;
StatusLabel.Text = "Connecting to server...";
}
void ClientAdministration_RestoredDownloadsEvent()
{
StatusLabel.Text = "Opening TorrentS...";
}
void ClientAdministration_ConnectedToServerEvent(bool Conncted)
{
if(Conncted)
StatusLabel.Text = "Connected to server...";
else
StatusLabel.Text = "Failed connect to server...";
Task.Delay(5000).Wait();
StatusLabel.Text ="Restoring downloads...";
}
private void Window_Loaded_1(object sender, RoutedEventArgs e)
{
///***I want the window to be open befor this code get excuted!!!!!***
ClientAdministration.ConnectToServer(UpdatedClientComputerURL, UpdatedClientComputerHostName);
ClientAdministration.RestoreDownloads();
}
}