本文整理匯總了C#中System.Threading.Thread.GetApartmentState方法的典型用法代碼示例。如果您正苦於以下問題:C# Thread.GetApartmentState方法的具體用法?C# Thread.GetApartmentState怎麽用?C# Thread.GetApartmentState使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Threading.Thread
的用法示例。
在下文中一共展示了Thread.GetApartmentState方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Main
static void Main(string[] args)
{
if (args.Length == 0)
{
Help();
Environment.Exit(0);
}
if ((args.Length % 2) != 0)
{
Console.WriteLine("Invalid number of arguments.");
Help();
Environment.Exit(-1);
}
int numberOfPresentations = args.Length / 2;
Thread[] conversionThreads = new Thread[numberOfPresentations];
// initialize threads
for (int presentationIndex = 0; presentationIndex < numberOfPresentations; ++presentationIndex)
{
String pptName = args[presentationIndex * 2];
String swfName = args[presentationIndex * 2 + 1];
Console.WriteLine("Convert \"" + pptName + "\" to \"" + swfName + "\"");
iSpringConverter converter = new iSpringConverter(pptName, swfName);
Thread thread = new Thread(converter.StartConversion);
ApartmentState astate = thread.GetApartmentState();
thread.SetApartmentState(ApartmentState.STA);
conversionThreads[presentationIndex] = thread;
}
// Start conversion
for (int presentationIndex = 0; presentationIndex < numberOfPresentations; ++presentationIndex)
{
conversionThreads[presentationIndex].Start();
}
// wait for threads
for (int presentationIndex = 0; presentationIndex < numberOfPresentations; ++presentationIndex)
{
conversionThreads[presentationIndex].Join();
}
}
示例2: GetApartmentState
protected static ApartmentState GetApartmentState(Thread thread)
{
return thread.GetApartmentState();
}
示例3: GetApartmentState
private static ApartmentState GetApartmentState(Thread thread)
{
return thread.GetApartmentState();
}