Skip to content

Commit

Permalink
Fix for intermittent crash on update check.
Browse files Browse the repository at this point in the history
  • Loading branch information
Razzmatazzz committed Apr 7, 2021
1 parent d81d644 commit e3cab03
Show file tree
Hide file tree
Showing 3 changed files with 616 additions and 385 deletions.
74 changes: 46 additions & 28 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -595,9 +595,15 @@ private void Server_StartingStopping(object sender, EventArgs e)
{
this.Dispatcher.Invoke(() =>
{
dgServers.CancelEdit();
dgServers.IsReadOnly = true;
RefreshDataGrid();
try
{
dgServers.CancelEdit();
dgServers.IsReadOnly = true;
RefreshDataGrid();
} catch (Exception ex)
{
logMessage($"Error refreshing server list on start/stop: {ex.Message}");
}
});
}
private void Server_StopFailed(object sender, ServerErrorEventArgs e)
Expand Down Expand Up @@ -859,38 +865,50 @@ public void logMessage(LogEntry entry)
{
if (!suppressLog)
{
if (txtLog.Document.Blocks.Count > 0)
try
{
txtLog.Document.Blocks.InsertBefore(txtLog.Document.Blocks.FirstBlock, (Block)entry);
}
else
{
txtLog.Document.Blocks.Add((Block)entry);
}
if (entry.Message.Contains('\n'))
{
lblLastMessage.Content = entry.Message.Split('\n')[0];
}
else
{
lblLastMessage.Content = entry.Message;
}
lblLastMessage.Foreground = new SolidColorBrush(entry.Color);
if (entry.Type == LogEntryType.Normal)
{
lblLastMessage.FontWeight = FontWeights.Normal;
}
else
if (txtLog.Document.Blocks.Count > 0)
{
txtLog.Document.Blocks.InsertBefore(txtLog.Document.Blocks.FirstBlock, (Block)entry);
}
else
{
txtLog.Document.Blocks.Add((Block)entry);
}
if (entry.Message.Contains('\n'))
{
lblLastMessage.Content = entry.Message.Split('\n')[0];
}
else
{
lblLastMessage.Content = entry.Message;
}
lblLastMessage.Foreground = new SolidColorBrush(entry.Color);
if (entry.Type == LogEntryType.Normal)
{
lblLastMessage.FontWeight = FontWeights.Normal;
}
else
{
lblLastMessage.FontWeight = FontWeights.Bold;
}
} catch (Exception ex)
{
lblLastMessage.FontWeight = FontWeights.Bold;
logMessage($"Error logging message: {ex.Message}");
}
}
});
if (Properties.Settings.Default.WriteAppLog)
{
StreamWriter writer = System.IO.File.AppendText(LogPath);
writer.WriteLine(entry.TimeStamp+": " +entry.Message);
writer.Close();
try
{
StreamWriter writer = System.IO.File.AppendText(LogPath);
writer.WriteLine(entry.TimeStamp + ": " + entry.Message);
writer.Close();
} catch (Exception ex)
{
logMessage($"Error writing to log file: {ex.Message}");
}
}
}

Expand Down
Loading

0 comments on commit e3cab03

Please sign in to comment.