private PackageManagerResponseImpl PerformCall(InvokeMemberBinder binder, object[] args) { using (var eventQueue = new ManualEventQueue()) { // create return message handler var responseHandler = new PackageManagerResponseImpl(); CurrentTask.Events += new GetCurrentRequestId(() => "" + Task.CurrentId); // unhook the old one if it's there. responseHandler.Clear(); // send OG message here! object callResult; base.TryInvokeMember(binder, args, out callResult); // will return when the final message comes thru. eventQueue.StillWorking = true; while (eventQueue.StillWorking && eventQueue.ResetEvent.WaitOne()) { eventQueue.ResetEvent.Reset(); while (eventQueue.Count > 0) { if (!Event <GetResponseDispatcher> .RaiseFirst().DispatchSynchronous(eventQueue.Dequeue())) { eventQueue.StillWorking = false; } } } if (PackageManagerResponseImpl.EngineRestarting) { Logger.Message("Going to try and re issue the call."); // Disconnect(); // the service is going to restart, let's call TryInvokeMember again. EngineServiceManager.WaitForStableMoment(); Connect().Wait(); return(PerformCall(binder, args)); } // this returns the final response back via the Task<*> return(responseHandler); } }
public Task DownloadPackages(IEnumerable<IPackage> packages) { cts = new CancellationTokenSource(); var impl = new PackageManagerResponseImpl(); return Task.Factory.StartNew(() => { foreach (var p in packages) { cts.Token.ThrowIfCancellationRequested(); waitDownload.WaitOne(); impl.RequireRemoteFile(p.CanonicalName, p.RemoteLocations, PackageManagerSettings.CoAppCacheDirectory + "\\packages", true); currentDownload = p.CanonicalName; waitDownload.Reset(); } }, cts.Token); }
private Task DownloadPackage(IPackage package) { var impl = new PackageManagerResponseImpl(); return Task.Factory.StartNew(() => impl.RequireRemoteFile(package.CanonicalName, package.RemoteLocations, PackageManagerSettings.CoAppCacheDirectory + "\\packages", false)); }