當前位置: 首頁>>代碼示例>>C#>>正文


C# Thread.GetApartmentState方法代碼示例

本文整理匯總了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();
            }
        }
開發者ID:pczy,項目名稱:Pub.Class,代碼行數:48,代碼來源:converter.cs

示例2: GetApartmentState

 protected static ApartmentState GetApartmentState(Thread thread)
 { 
     return thread.GetApartmentState();
 }
開發者ID:jeme,項目名稱:nunit-framework,代碼行數:4,代碼來源:ThreadingTests.cs

示例3: GetApartmentState

 private static ApartmentState GetApartmentState(Thread thread)
 { 
     return thread.GetApartmentState();
 }
開發者ID:haf,項目名稱:nunit-framework,代碼行數:4,代碼來源:ThreadingTests.cs


注:本文中的System.Threading.Thread.GetApartmentState方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。