/// <summary> /// Begins checking for an update to HandBrake. /// </summary> /// <param name="callback"> /// The method that will be called when the check is finished. /// </param> /// <param name="debug"> /// Whether or not to execute this in debug mode. /// </param> /// <param name="url"> /// The url. /// </param> /// <param name="currentBuild"> /// The current Build. /// </param> /// <param name="skipBuild"> /// The skip Build. /// </param> /// <param name="currentVersion"> /// The current Version. /// </param> public static void BeginCheckForUpdates(AsyncCallback callback, bool debug, string url, int currentBuild, int skipBuild, string currentVersion) { ThreadPool.QueueUserWorkItem(new WaitCallback(delegate { try { // Initialize variables WebRequest request = WebRequest.Create(url); WebResponse response = request.GetResponse(); IAppcastReader reader = new AppcastReader(); // Get the data, convert it to a string, and parse it into the AppcastReader reader.GetUpdateInfo(new StreamReader(response.GetResponseStream()).ReadToEnd()); // Further parse the information string build = reader.Build; int latest = int.Parse(build); int current = currentBuild; int skip = skipBuild; // If the user wanted to skip this version, don't report the update if (latest == skip) { UpdateCheckInformation info = new UpdateCheckInformation { NewVersionAvailable = false, BuildInformation = null }; callback(new UpdateCheckResult(debug, info)); return; } UpdateCheckInformation info2 = new UpdateCheckInformation { NewVersionAvailable = latest > current, BuildInformation = reader }; callback(new UpdateCheckResult(debug, info2)); } catch (Exception exc) { callback(new UpdateCheckResult(debug, new UpdateCheckInformation { Error = exc })); } })); }
/// <summary> /// Initializes a new instance of the <see cref="HandBrake.Framework.Model.UpdateCheckResult"/> class. /// </summary> /// <param name="asyncState"> /// The async state. /// </param> /// <param name="info"> /// The info. /// </param> public UpdateCheckResult(object asyncState, UpdateCheckInformation info) { this.AsyncState = asyncState; this.Result = info; }