public async Task UpdateFileAndRestart()
        {
            CancellationTokenSource cts = new CancellationTokenSource();
            var fixture = new NodeEndToEndTests.TestFixture();
            var blob1 = UpdateOutputName("testblob", "first", fixture);

            await fixture.Host.StopAsync();
            var config = fixture.Host.ScriptConfig;

            ExceptionDispatchInfo exception = null;

            using (var manager = new ScriptHostManager(config))
            {
                // Background task to run while the main thread is pumping events at RunAndBlock(). 
                Thread t = new Thread(_ =>
                   {
                       // don't start until the manager is running
                       TestHelpers.Await(() => manager.State == ScriptHostState.Running).Wait();

                       try
                       {
                           // Wait for initial execution.
                           TestHelpers.Await(() =>
                           {
                               bool exists = blob1.Exists();
                               return exists;
                           }, timeout: 10 * 1000).Wait();

                           // This changes the bindings so that we now write to blob2
                           var blob2 = UpdateOutputName("first", "second", fixture);

                           // wait for newly executed
                           TestHelpers.Await(() =>
                           {
                               bool exists = blob2.Exists();
                               return exists;
                           }, timeout: 30 * 1000).Wait();
                       }
                       catch (Exception ex)
                       {
                           exception = ExceptionDispatchInfo.Capture(ex);
                       }

                       cts.Cancel();
                   });
                t.Start();

                manager.RunAndBlock(cts.Token);

                t.Join();

                Assert.True(exception == null, exception?.SourceException?.ToString());
            }
        }
        public async Task UpdateFileAndRestart()
        {
            Random r = new Random();

            CancellationTokenSource cts = new CancellationTokenSource();

            var fixture = new NodeEndToEndTests.TestFixture();
            var blob1 = UpdateOutputName("testblob", "first", fixture);

            await fixture.Host.StopAsync();
            var config = fixture.Host.ScriptConfig;            

            using (var manager = new ScriptHostManager(config))
            {
                // Background task to run while the main thread is pumping events at RunAndBlock(). 
                Thread t = new Thread(_ =>
                   {
                       // Wait for initial execution.
                       TestHelpers.Await(() =>
                       {
                           return blob1.Exists();
                       }, timeout: 10 * 1000).Wait();

                       // This changes the bindings so that we now write to blob2
                       var blob2 = UpdateOutputName("first", "second", fixture);

                       // wait for newly executed
                       TestHelpers.Await(() =>
                       {
                           return blob2.Exists();
                       }, timeout: 10 * 1000).Wait();

                       manager.Stop();
                   });
                t.Start();                           

                manager.RunAndBlock(cts.Token);

                t.Join();
            }
        }