Skip to content

Commit

Permalink
Fix cross-thread issue, removed some callback in example_dotnet
Browse files Browse the repository at this point in the history
  • Loading branch information
Herve-M committed Jan 28, 2016
1 parent cd81a02 commit c27d034
Showing 1 changed file with 2 additions and 67 deletions.
69 changes: 2 additions & 67 deletions examples/example_dotnet/WinSparkleDemoForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@ public WinSparkleDemoForm()
return;
}
//Callback
_sparkleNet.SetCanShutdownCallback(this.CanShutDownCallback);
_sparkleNet.SetShutdownRequestCallback(this.ShutDownRequestCallback);
_sparkleNet.SetDidFindUpdateCallback(this.DidFindAnUpdateCallback);
_sparkleNet.SetDidNotFindUpdateCallback(this.DidNotFindAnUpdateCallback);
_sparkleNet.SetUpdateCancelledCallback(this.UpdateCancelledCallback);
_sparkleNet.SetErrorCallback(this.ErrorCallback);
_sparkleNet.SetShutdownRequestCallback(this.ShutDownRequestCallback);
//Init
_sparkleNet.Initialize();
_sparkleNet.CheckForUpdate();
Expand Down Expand Up @@ -66,60 +62,6 @@ private void btn_close_Click(object sender, EventArgs e)
this.Close();
}

private bool CanShutDownCallback()
{
try
{
var result = MessageBox.Show(@"Here you can simulate if the application can be closed or not to proceed the update", @"CanShutDownCallback",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
return result == DialogResult.Yes;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
}

private void DidFindAnUpdateCallback()
{
try
{
MessageBox.Show(@"Callback called if an update has been found.", @"DidFindUpdateCallback",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

private void DidNotFindAnUpdateCallback()
{
try
{
MessageBox.Show(@"Callback called if an update hasn't been found.", @"DidNotFindUpdateCallback",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

private void UpdateCancelledCallback()
{
try
{
MessageBox.Show(@"Callback called if an update has been cancelled/ignored by user.", @"UpdateCancelledCallback",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

private void ErrorCallback()
{
try
Expand All @@ -137,14 +79,7 @@ private void ShutDownRequestCallback()
{
try
{
if (System.Windows.Forms.Application.MessageLoop)
{
System.Windows.Forms.Application.Exit();
}
else
{
System.Environment.Exit(1);
}
this.BeginInvoke(new MethodInvoker(this.Close));
}
catch (Exception ex)
{
Expand Down

0 comments on commit c27d034

Please sign in to comment.