本文整理汇总了C#中System.Management.Automation.Runspaces.Runspace.Close方法的典型用法代码示例。如果您正苦于以下问题:C# Runspace.Close方法的具体用法?C# Runspace.Close怎么用?C# Runspace.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Management.Automation.Runspaces.Runspace
的用法示例。
在下文中一共展示了Runspace.Close方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Exec
public static Collection<PSObject> Exec(Runspace runspace, string script)
{
runspace.Open();
PowerShell shell = PowerShell.Create();
shell.Runspace = runspace;
shell.AddScript(script);
Collection<PSObject> ret = shell.Invoke();
try
{
shell.Dispose();
runspace.Close();
}
catch (Exception)
{ }
return ret;
}
示例2: CloseRunspace
internal void CloseRunspace(Runspace runspace)
{
try
{
if (runspace != null && runspace.RunspaceStateInfo.State == RunspaceState.Opened)
{
runspace.Close();
runspaceConfiguration = null;
}
}
catch (Exception ex)
{
HostedSolutionLog.LogError("Runspace error", ex);
}
}
示例3: DestroyRunspace
protected void DestroyRunspace(Runspace runspace)
{
runspace.Events.ForwardEvent -= new EventHandler<PSEventArgs>(this.OnRunspaceForwardEvent);
runspace.Close();
runspace.Dispose();
lock (this.runspaceList)
{
this.runspaceList.Remove(runspace);
this.totalRunspaces = this.runspaceList.Count;
}
}
示例4: CloseRunspace
internal void CloseRunspace(Runspace runspace)
{
try
{
if (runspace != null && runspace.RunspaceStateInfo.State == RunspaceState.Opened)
{
runspace.Close();
}
}
catch (Exception ex)
{
ExchangeLog.LogError("Runspace error", ex);
}
}
示例5: CloseRunspace
protected void CloseRunspace(Runspace runspace)
{
try
{
if (runspace != null && runspace.RunspaceStateInfo.State == RunspaceState.Opened)
{
runspace.Close();
}
}
catch (Exception ex)
{
Log.WriteError("Runspace error", ex);
}
}