ManualResetEvent hanging

I am evaluating WyUpdate and WyBuild for a project I'm working on for work. I have a Console application that I've been using for the last 6 months, and I've tried adding to it the code to work with WyUpdate from the sample. The app ran the first time, when there was an update, and it updated beautifully. However, now that there's no update available, it seems to be hanging on the line:

resetEvent.WaitOne();

I've pretty much stolen the sample code, and it's just not working 100%. Can anyone tell me what I'm doing wrong? My code:

using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Threading;using wyDay.Controls;

namespace MyApplication{ static class Program { static AutomaticUpdaterBackend auBackend; static readonly ManualResetEvent resetEvent = new ManualResetEvent(false); private static string _infile = null; private static string _indir = null; private static bool _showHelp = false; private static string _outfile; private static bool _suppressFiles = false; private static string _templatefile = null;

static void Main(string[] args) { #region Argument Parsing

// Argument parsing here

#endregion

#region Update Checks

auBackend = new AutomaticUpdaterBackend { //TODO: set a unique string. For instance, "appname-companyname" GUID = "AccuvantWorksheetApplication",

// With UpdateType set to Automatic, you're still in charge of // checking for updates, but the AutomaticUpdaterBackend // continues with the downloading and extracting automatically. UpdateType = UpdateType.Automatic };

auBackend.ReadyToBeInstalled += auBackend_ReadyToBeInstalled; auBackend.UpdateSuccessful += auBackend_UpdateSuccessful;

//TODO: use the failed events for logging & error reporting: // CheckingFailed, DownloadingFailed, ExtractingFailed, UpdateFailed

// the functions to be called after all events have been set. auBackend.Initialize(); auBackend.AppLoaded();

// sees if you checked in the last 10 days, if not it rechecks CheckEvery10Days();

// Blocks until "resetEvent.Set()" on another thread resetEvent.WaitOne();

#endregion

DoStuff(_infile, _indir, _outfile, _suppressFiles); }

private static void DoStuff(string infile, string indir, string outfile, bool suppress_files) { // Specific implementation of application here }

static void CheckEvery10Days() { auBackend.ForceCheckForUpdate(); }

static void auBackend_UpdateSuccessful(object sender, SuccessArgs e) { Console.WriteLine("Successfully updated to version " + e.Version); Console.WriteLine("Changes: "); Console.WriteLine(auBackend.Changes); }

static void auBackend_ReadyToBeInstalled(object sender, EventArgs e) { if (auBackend.UpdateStepOn == UpdateStepOn.UpdateReadyToInstall) { auBackend.InstallNow(); } } }}

The code tells you exactly why it's stuck there:

// Blocks until "resetEvent.Set()" on another threadresetEvent.WaitOne(); 

So you need to call resetEvent.Set() (for example in the Events from the AutomaticUpdater) to "resume" execution of that thread.

It's probably easier if you test the AutomaticUpdater in a Windows Forms app, because then you don't have to worry about these threading problems.

That makes sense. I guess I was just up too late coding.

Thanks!