多线程VB.NET,Powershell和Exchange 2010 [英] Multithreaded VB.NET, Powershell and Exchange 2010

查看:53
本文介绍了多线程VB.NET,Powershell和Exchange 2010的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VB.NET VS2010中编写了一个程序,它将邮箱提取请求提交给Exchange 2010环境。它显示状态列表视图,显示已提交,已排队,正在进行,已完成和已错误的邮箱。所有的Powershell命令都是同步提交的。



当您处理10或20个邮箱时,用户界面很好,但是当您提交数百个时,它变得很麻烦。



我想将提交的内容分解为20个邮箱块。我的想法是提供最多10个状态表单,每个表单包含不超过20个邮箱。每个表单都是一个单独的线程,然后提交然后监视邮箱提取的状态。



我的问题是我应该在Exchange中创建一个Powershell运行空间并传递它每个线程或者更好地在每个线程中创建一个单独的运行空间。



任何想法都会受到赞赏。

I have written a program in VB.NET VS2010 that will submit mailbox extract requests to an Exchange 2010 environment. It presents a status list view that shows submitted, queued, in progress, complete, and erred mailboxes. All of the Powershell commands are submitted synchronously.

When you are dealing with 10 or 20 mailboxes the user interface is fine, but when you are submitting hundreds it becomes cumbersome.

I would like to break up the submissions into 20 mailbox chunks. My thought is to present up to 10 status forms that would contain no more than 20 mailboxes per form. Each form would be an individual thread that would submit then monitor the status of the mailbox extracts.

My question is should I create a single Powershell runspace into Exchange and pass it to each thread or is it better to create an individual runspace in each thread.

Any thoughts would be appreciated.

推荐答案

您的powershell运行空间可能不是多线程的,因此您不能拥有共享空间,因此最好每个线程创建一个。

来自http://msdn.microsoft.com/en-us/library /system.management.automation.runspaces.runspace%28v=vs.85%29.aspx [ ^ ]

Your powershell runspace is probably not multithreaded so you can't have a shared one, so it is probably best if you create one per thread.
From http://msdn.microsoft.com/en-us/library/system.management.automation.runspaces.runspace%28v=vs.85%29.aspx[^]
Q. uote:

此类型的任何公共静态(Visual Basic中的Shared)成员都是线程安全的。任何实例成员都不保证是线程安全的。

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.





如果您使用的是.net 4使用任务而不是线程。


我学到的一些东西。



你在每个帖子中创建一个是正确的。



最好在每次需要时创建一个运行空间,而不是在线程持续时间内只创建一个运行空间。由于创建运行空间并不是一项快速的任务,因此性能受到了轻微打击。



就任务而言,作为一种旧的MAPI类型,线程池是邪恶的。由于我使用poling来监视和维护而不是中断,所以线程工作正常。



谢谢
A couple of things I learned.

You were correct in creating one per thread.

It is better to create a runspace for each and every time you need one rather than creating only one for the duration of the thread. There is a mild performance hit as creating the runspace is no speedy task.

As far as the Tasks go, being an old MAPI type, threadpools are evil. Since I use poling to monitor and maintain rather than interrupts , threads work just fine.

Thanks


这篇关于多线程VB.NET,Powershell和Exchange 2010的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆