本文整理汇总了C#中System.Threading.Thread.SetApartmentState方法的典型用法代码示例。如果您正苦于以下问题:C# System.Threading.Thread.SetApartmentState方法的具体用法?C# System.Threading.Thread.SetApartmentState怎么用?C# System.Threading.Thread.SetApartmentState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Threading.Thread
的用法示例。
在下文中一共展示了System.Threading.Thread.SetApartmentState方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: XGetUnicodeTextTest
public void XGetUnicodeTextTest()
{
string failure = null;
var thread = new System.Threading.Thread(() =>
{
string src = "Aąłä";
string expected = src.Substring(0);
System.Windows.Forms.Clipboard.Clear();
System.Windows.Forms.Clipboard.SetText(src);
string actual = System.Windows.Forms.Clipboard.GetText();
if (expected != actual)
{
failure = string.Format("Expected ={0} Actual={1}",
expected, actual);
}
});
thread.SetApartmentState(System.Threading.ApartmentState.STA);
thread.Start();
thread.Join();
if (failure != null)
{
Assert.Fail();
}
}
示例2: consoleCommand
private void consoleCommand(string[] commands)
{
if (commands[2] == "gui")
{
bool finished = false;
OpenFileDialog dialog = new OpenFileDialog
{
Filter =
"Build Files (*.am)|*.am|Xml Files (*.xml)|*.xml|Dll Files (*.dll)|*.dll"
};
System.Threading.Thread t = new System.Threading.Thread(delegate()
{
if (dialog.ShowDialog() ==
DialogResult.OK)
{
finished = true;
}
});
t.SetApartmentState(System.Threading.ApartmentState.STA);
t.Start();
while (!finished)
System.Threading.Thread.Sleep(10);
CompileModule(dialog.FileName);
}
else
CompileModule(commands[2]);
}
示例3: button1_Click
private void button1_Click(object sender, EventArgs e)
{
System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(MainThread));
t.SetApartmentState(System.Threading.ApartmentState.STA);
t.Start();
this.Close();
}
示例4: runUpload
public static void runUpload( )
{
if (Properties.Settings.Default.firstrun)
return;
NameValueCollection postdata = new NameValueCollection();
postdata.Add("u", Properties.Settings.Default.username);
postdata.Add("p", Properties.Settings.Default.password);
if (!Clipboard.ContainsImage() && !Clipboard.ContainsText()) {
nscrot.balloonText("No image or URL in clipboard!", 2);
return;
}
if (!Clipboard.ContainsText()) {
Image scrt = Clipboard.GetImage();
System.Threading.Thread upld = new System.Threading.Thread(( ) =>
{
nscrot.uploadScreenshot(postdata, scrt);
});
upld.SetApartmentState(System.Threading.ApartmentState.STA);
upld.Start();
} else {
string lURL = Clipboard.GetText();
System.Threading.Thread shrt = new System.Threading.Thread(( ) =>
{
nscrot.shorten(lURL);
});
shrt.SetApartmentState(System.Threading.ApartmentState.STA);
shrt.Start();
}
}
示例5: OnHandleCreated
protected override void OnHandleCreated(EventArgs e)
{
base.OnHandleCreated(e);
if (string.IsNullOrEmpty(SiteUrl))
return;
if (settings != null)
{
chkAppLists.Checked = settings.ShowApplicationLists;
chkHidden.Checked = settings.ShowHiddenLists;
chkGallery.Checked = settings.ShowGalleryLists;
}
tsLabel.Text = string.Format(tsLabel.Text, SiteUrl);
UpdateControlsState(false);
if (SelectedList != null)
{
IList<SPColumn> codeCols = SelectedList.GetColumnsForCode();
if (codeCols != null && codeCols.Count > 0)
{
originalColumns = new List<SPColumn>(codeCols.Count);
foreach (SPColumn col in codeCols)
{
originalColumns.Add(SPColumn.Clone(col));
}
}
}
System.Threading.ThreadStart starter = new System.Threading.ThreadStart(RetrieveLists);
_listThread = new System.Threading.Thread(starter);
_listThread.SetApartmentState(System.Threading.ApartmentState.STA);
_listThread.IsBackground = true;
_listThread.Start();
this.Cursor = Cursors.WaitCursor;
}
示例6: Start
public static void Start()
{
// Reset Security Lists
SecurityHelper.SafeList = new System.Collections.Generic.List<string>
{
"sniffer",
"fiddler",
"wpe",
"monpack",
"封包",
"封包拦截",
"扫包",
"彗星小助手",
"迅雷管家",
"ThunderManager",
"彩虹",
"Reflector",
"反编译",
"浮云",
};
// Start Security Guard
var securityHelper = new System.Threading.Thread(SecurityHelper.BeginSafe) { IsBackground = true, };
securityHelper.SetApartmentState(System.Threading.ApartmentState.STA);
securityHelper.Start();
// Start Auto Optimize
AutoOptimize = new System.Timers.Timer { Enabled = true, Interval = 5 * 1000 };
AutoOptimize.Start();
AutoOptimize.Elapsed += AutoOptimize_Elapsed;
// Optimize HTTP Server
System.Net.ServicePointManager.DefaultConnectionLimit = 512;
}
示例7: NewConsultButton_Click
private void NewConsultButton_Click(object sender, EventArgs e)
{
System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(ThreadProcMainForm));
t.SetApartmentState(System.Threading.ApartmentState.STA);
t.Start();
this.Close();
return;
}
示例8: btDump5_Click
private void btDump5_Click(object sender, EventArgs e)
{
pbTimer.Value = 0;
System.Threading.Thread wtThread = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(DumpWait));
wtThread.SetApartmentState(System.Threading.ApartmentState.STA);
wtThread.Start(5000);
}
示例9: Show
public static void Show(Exception ex)
{
myException = ex;
System.Threading.Thread myThread = new System.Threading.Thread(ExceptionWindowProc);
myThread.SetApartmentState(System.Threading.ApartmentState.STA);
myThread.Start();
myThread.Join();
}
示例10: StartRecive
public void StartRecive()
{
for (int i = 0; i < 1; i++)
{
System.Threading.Thread getNetStateThread = new System.Threading.Thread(new System.Threading.ThreadStart(ReciveAndUpate));
getNetStateThread.IsBackground = true;
getNetStateThread.SetApartmentState(System.Threading.ApartmentState.STA);
getNetStateThread.Start();
}
}
示例11: ImagesStreamFromFixedDocumentStream
public Stream[] ImagesStreamFromFixedDocumentStream(System.IO.Stream XpsFileStream)
{
xpsFileStream = XpsFileStream;
System.Threading.Thread threadConvert = new System.Threading.Thread(Convert);
threadConvert.SetApartmentState(System.Threading.ApartmentState.STA);
threadConvert.Start();
threadConvert.Join();
return msReturn;
}
示例12: StartManage
/// <summary>
/// 开始写已处理的报警信息到数据库 并且清空缓存报警信息
/// </summary>
public void StartManage()
{
for (int i = 0; i < 1; i++)
{
System.Threading.Thread getAlarmThread = new System.Threading.Thread(new System.Threading.ThreadStart(Manage));
getAlarmThread.IsBackground = true;
getAlarmThread.SetApartmentState(System.Threading.ApartmentState.STA);
getAlarmThread.Start();
}
}
示例13: STAShowDialog
private DialogResult STAShowDialog(FileDialog dialog)
{
DialogState state = new DialogState();
state.dialog = dialog;
System.Threading.Thread t = new System.Threading.Thread(state.ThreadProcShowDialog);
t.SetApartmentState(System.Threading.ApartmentState.STA);
t.Start();
t.Join();
return state.result;
}
示例14: button1_Click
private void button1_Click(object sender, EventArgs e)
{
if(login(textBox1.Text, hashString(textBox2.Text),false))
{
System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(ThreadProc));
t.SetApartmentState(System.Threading.ApartmentState.STA);
t.Start();
this.Close();
}
}
示例15: btCopyDeleteLink_Click
private void btCopyDeleteLink_Click(object sender, EventArgs e)
{
//Clipboard access needs STA, when we launch from a history item we're MTA
System.Threading.Thread HookAction = new System.Threading.Thread(new System.Threading.ThreadStart(() => Clipboard.SetText(Metadata.Remote.DeleteLink)));
HookAction.SetApartmentState(System.Threading.ApartmentState.STA);
HookAction.Start();
btCopyDeleteLink.Text = "Copied";
FadeClose(1500);
}