public void Close() { try { if (AgentType == eAgentType.Service) { if (mGingerNodeInfo != null) { // this is plugin driver GingerNodeProxy GNP = new GingerNodeProxy(mGingerNodeInfo); GNP.GingerGrid = WorkSpace.Instance.LocalGingerGrid; GNP.CloseDriver(); if (mProcess != null) { // mProcess.Kill(); //mProcess.Close(); //GingerCore.General.DoEvents(); mProcess.CloseMainWindow(); } mGingerNodeInfo = null; // GNP.Shutdown(); return; } } if (Driver == null) { return; } Driver.IsDriverRunning = false; if (Driver.Dispatcher != null) { Driver.Dispatcher.Invoke(() => { Driver.CloseDriver(); Thread.Sleep(1000); }); } else { Driver.CloseDriver(); } if (MSTATask != null) { // Using Cancelleation token soucrce to cancel CancelTask = new BackgroundWorker(); CancelTask.DoWork += new DoWorkEventHandler(CancelTMSTATask); CancelTask.RunWorkerAsync(); } Driver = null; } finally { OnPropertyChanged(Fields.Status); OnPropertyChanged(Fields.IsWindowExplorerSupportReady); } }
public void Close() { try { if (AgentType == eAgentType.Service) { if (gingerNodeInfo != null) { // this is plugin driver on local machine GingerNodeProxy.GingerGrid = WorkSpace.Instance.LocalGingerGrid; GingerNodeProxy.CloseDriver(); gingerNodeInfo.Status = GingerNodeInfo.eStatus.Ready; if (mProcess != null) // it means a new plugin process was started for this agent - so we close it { // Remove the node from the grid WorkSpace.Instance.LocalGingerGrid.NodeList.Remove(gingerNodeInfo); // Close the plugin process mProcess.CloseMainWindow(); } GingerNodeProxy = null; gingerNodeInfo = null; return; } else { if (GingerNodeProxy != null) { // Running on Remote Grid GingerNodeProxy.CloseDriver(); GingerNodeProxy.Disconnect(); GingerNodeProxy = null; } } } if (Driver == null) { return; } Driver.IsDriverRunning = false; if (Driver.Dispatcher != null) { Driver.Dispatcher.Invoke(() => { Driver.CloseDriver(); Thread.Sleep(1000); }); } else { Driver.CloseDriver(); } if (MSTATask != null) { // Using cancellation token source to cancel CancelTask = new BackgroundWorker(); CancelTask.DoWork += new DoWorkEventHandler(CancelTMSTATask); CancelTask.RunWorkerAsync(); } Driver = null; } finally { OnPropertyChanged(Fields.Status); OnPropertyChanged(Fields.IsWindowExplorerSupportReady); } }
public void ParallelRunTest() { //Arrange ActPlugIn a1 = new ActPlugIn() { ActionId = "A1" }; ActPlugIn a2 = new ActPlugIn() { ActionId = "A1" }; ActPlugIn a3 = new ActPlugIn() { ActionId = "A1" }; ActPlugIn a4 = new ActPlugIn() { ActionId = "A1" }; ActPlugIn a5 = new ActPlugIn() { ActionId = "A1" }; ActPlugIn b1 = new ActPlugIn() { ActionId = "A1" }; ActPlugIn b2 = new ActPlugIn() { ActionId = "A1" }; ActPlugIn b3 = new ActPlugIn() { ActionId = "A1" }; ActPlugIn b4 = new ActPlugIn() { ActionId = "A1" }; ActPlugIn b5 = new ActPlugIn() { ActionId = "A1" }; // Act // We run on 2 drivers in parralel Task t1 = Task.Factory.StartNew(() => { GingerNodeInfo GNI1 = GG.NodeList[0]; GingerNodeProxy GNP1 = new GingerNodeProxy(GNI1); GNP1.GingerGrid = GG; GNP1.Reserve(); GNP1.StartDriver(); RunAction(a1, GNP1); RunAction(a2, GNP1); RunAction(a3, GNP1); RunAction(a4, GNP1); RunAction(a5, GNP1); GNP1.CloseDriver(); }); Task t2 = Task.Factory.StartNew(() => { GingerNodeInfo GNI2 = GG.NodeList[1]; GingerNodeProxy GNP2 = new GingerNodeProxy(GNI2); GNP2.GingerGrid = GG; GNP2.Reserve(); GNP2.StartDriver(); RunAction(b1, GNP2); RunAction(b2, GNP2); RunAction(b3, GNP2); RunAction(b4, GNP2); RunAction(b5, GNP2); GNP2.CloseDriver(); }); t1.Wait(); t2.Wait(); // Assert Assert.AreEqual(a1.Error, null); Assert.AreEqual(a1.ExInfo, "A1 Result"); Assert.AreEqual(a2.Error, null); Assert.AreEqual(a2.ExInfo, "A1 Result"); Assert.AreEqual(a3.Error, null); Assert.AreEqual(a3.ExInfo, "A1 Result"); Assert.AreEqual(a4.Error, null); Assert.AreEqual(a4.ExInfo, "A1 Result"); Assert.AreEqual(a5.Error, null); Assert.AreEqual(a5.ExInfo, "A1 Result"); Assert.AreEqual(b1.Error, null); Assert.AreEqual(b1.ExInfo, "A1 Result"); Assert.AreEqual(b2.Error, null); Assert.AreEqual(b2.ExInfo, "A1 Result"); Assert.AreEqual(b3.Error, null); Assert.AreEqual(b3.ExInfo, "A1 Result"); Assert.AreEqual(b4.Error, null); Assert.AreEqual(b4.ExInfo, "A1 Result"); Assert.AreEqual(b5.Error, null); Assert.AreEqual(b5.ExInfo, "A1 Result"); }