Skip to content

Commit

Permalink
Fix for disposing of NetSparkle to remove held event references
Browse files Browse the repository at this point in the history
  • Loading branch information
jimgraham committed Mar 29, 2012
1 parent 3e45f15 commit 663a509
Showing 1 changed file with 37 additions and 9 deletions.
46 changes: 37 additions & 9 deletions NetSparkle/NetSparkle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,15 @@ public bool IsUpdateLoopRunning
/// The configuration.
/// </summary>
public NetSparkleConfiguration Configuration { get; set; }

/// <summary>
/// Gets or sets the app cast URL
/// </summary>
public string AppcastUrl
{
get { return _AppCastUrl; }
set { _AppCastUrl = value; }
}
#endregion

/// <summary>
Expand Down Expand Up @@ -314,17 +323,32 @@ public void Dispose()
/// </summary>
private void UnregisterEvents()
{
if ( this.ProgressWindow != null )
{
this.ProgressWindow.InstallAndRelaunch -= new EventHandler(OnProgressWindowInstallAndRelaunch);
}
ServicePointManager.ServerCertificateValidationCallback -= RemoteCertificateValidation;
_worker.DoWork -= new DoWorkEventHandler(OnWorkerDoWork);
_worker.ProgressChanged -= new ProgressChangedEventHandler(OnWorkerProgressChanged);
_worker = null;

if (_webDownloadClient != null)
{
_webDownloadClient.DownloadProgressChanged -= new DownloadProgressChangedEventHandler(this.ProgressWindow.OnClientDownloadProgressChanged);
if (this.ProgressWindow != null)
{
_webDownloadClient.DownloadProgressChanged -= new DownloadProgressChangedEventHandler(this.ProgressWindow.OnClientDownloadProgressChanged);
}
_webDownloadClient.DownloadFileCompleted -= new AsyncCompletedEventHandler(OnWebDownloadClientDownloadFileCompleted);
_webDownloadClient = null;
}
if (this.UserWindow != null)
{
this.UserWindow.UserResponded -= new EventHandler(OnUserWindowUserResponded);
this.UserWindow = null;
}

if (this.ProgressWindow != null)
{
this.ProgressWindow.InstallAndRelaunch -= new EventHandler(OnProgressWindowInstallAndRelaunch);
this.ProgressWindow = null;
}

}

/// <summary>
Expand Down Expand Up @@ -977,11 +1001,15 @@ void OnWebDownloadClientDownloadFileCompleted(object sender, AsyncCompletedEvent
}
}
}
this.ProgressWindow.IsDownloadDSAValid = isDSAOk;
if (this.ProgressWindow != null)
{
this.ProgressWindow.IsDownloadDSAValid = isDSAOk;
}
}
if (this.ProgressWindow != null)
{
this.ProgressWindow.OnClientDownloadFileCompleted(sender, e);
}
this.ProgressWindow.OnClientDownloadFileCompleted(sender, e);
}


}
}

0 comments on commit 663a509

Please sign in to comment.