moved some network code to the networking assembly

This commit is contained in:
LukePulverenti
2013-02-23 12:54:51 -05:00
parent 17c1fd5760
commit 465f0cc1e2
43 changed files with 505 additions and 179 deletions

View File

@@ -634,7 +634,7 @@ namespace MediaBrowser.Controller.MediaInfo
await AudioImageResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
await process.RunAsync().ConfigureAwait(false);
await RunAsync(process).ConfigureAwait(false);
AudioImageResourcePool.Release();
@@ -713,7 +713,7 @@ namespace MediaBrowser.Controller.MediaInfo
await AudioImageResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
await process.RunAsync().ConfigureAwait(false);
await RunAsync(process).ConfigureAwait(false);
AudioImageResourcePool.Release();
@@ -768,7 +768,7 @@ namespace MediaBrowser.Controller.MediaInfo
await AudioImageResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
await process.RunAsync().ConfigureAwait(false);
await RunAsync(process).ConfigureAwait(false);
AudioImageResourcePool.Release();
@@ -971,6 +971,23 @@ namespace MediaBrowser.Controller.MediaInfo
((Process)sender).Dispose();
}
/// <summary>
/// Provides a non-blocking method to start a process and wait asynchronously for it to exit
/// </summary>
/// <param name="process">The process.</param>
/// <returns>Task{System.Boolean}.</returns>
private static Task<bool> RunAsync(Process process)
{
var tcs = new TaskCompletionSource<bool>();
process.EnableRaisingEvents = true;
process.Exited += (sender, args) => tcs.SetResult(true);
process.Start();
return tcs.Task;
}
/// <summary>
/// Sets the error mode.
/// </summary>