积极答复者
Lync export archiving data sometime is fast sometime is very slow when use C# invoke the cmdlets.

问题
-
Hello,
Sometimes the lync export archiving data is not works but sometimes is fast that I use C# invoke lync cmdlets.
below is my general codes, is it has any issue? I am confuse and need your help.
for (int i = 0; i < 10; i++)
private static void Export(object pool)
{
ThreadPool.QueueUserWorkItem(Export, null);
}
while (true)
{
if (doneCount == 10)
{
Console.WriteLine("All missions done!");
break;
}
}
{
using (RunspacePool p = CreateRunspacePoolForLync())
{
try
{
p.Open();
//export archiving data from lync that use powershell cmdlets
ExportCsArchivingDataByDBInstance(p, "archivingsql.test.com", new DateTime(2015, 6, 1),
DateTime.Now, false, "c:\\test",
"user1@test.com");
doneCount++;
Console.WriteLine("Completed {0} items", doneCount);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
p.Close();
}
}
}- 已编辑 EinsteinSu 2015年7月2日 9:11
答案
-
I use two approaches to invoke the lync powershell command
one is through pipeline invoke it. it always time out. sucha as below:
using (PowerShell powershell = PowerShell.Create())
{powershell.AddCommand(cmd);
...
}
another is execute cmdlet script immediatly. it is ok. such as below:
using (PowerShell powershell = PowerShell.Create())
{powershell.AddScript(script);
...
}
I don't know why? I waste many time to figure out it.
- 已标记为答案 EinsteinSu 2015年7月17日 3:31
全部回复
-
Hi EinsteinSu,
Do you have any "lock" action or wait handles in your powershell cmdlets? Now based on your code, you are runnning ten threads each will export your cmdlets. The ThreadPool function can not help you manage your threads here(Due to using the same command and the same instance). Please notice that MSDN has the following description:
The thread pool enables you to use threads more efficiently by providing your application with a pool of worker threads that are managed by the system. Which does not mean you don't need to manage the same object yourself.
Best regards,
Barry
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey. -
I use two approaches to invoke the lync powershell command
one is through pipeline invoke it. it always time out. sucha as below:
using (PowerShell powershell = PowerShell.Create())
{powershell.AddCommand(cmd);
...
}
another is execute cmdlet script immediatly. it is ok. such as below:
using (PowerShell powershell = PowerShell.Create())
{powershell.AddScript(script);
...
}
I don't know why? I waste many time to figure out it.
- 已标记为答案 EinsteinSu 2015年7月17日 3:31