C#中的线程问题 [英] Threading problem in C#
本文介绍了C#中的线程问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的朋友
我在计时器上从剪贴板读取数据时遇到错误,我的错误是
Dear friends
I am facing an error while I am reading data from clipboard on a timer my error is
ex = {"Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it."}
我该如何解决这个问题
[edit]只需修正主题中的错字[/edit]
how can i solve this problem
[edit]Just fixing the typo in the subject[/edit]
推荐答案
您需要在主要方法上添加STAThreadAttribute:
You need to add STAThreadAttribute on the main method:
C#
[STAThread]
static void Main(string[] args)
{
}
有关更多信息,请参见此处:
^ ]
See here for more info:
http://blogs.msdn.com/b/smondal/archive/2010/09/08/current-thread-must-be-set-to-single-thread-apartment-sta-mode-before-ole-calls-can-be-made.aspx[^]
这篇关于C#中的线程问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文