当前位置: 首页>>代码示例>>C#>>正文


C# Thread.TrySetApartmentState方法代码示例

本文整理汇总了C#中System.Threading.Thread.TrySetApartmentState方法的典型用法代码示例。如果您正苦于以下问题:C# Thread.TrySetApartmentState方法的具体用法?C# Thread.TrySetApartmentState怎么用?C# Thread.TrySetApartmentState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Threading.Thread的用法示例。


在下文中一共展示了Thread.TrySetApartmentState方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: myScreenshot

 private static void myScreenshot()
 {
     var thread = new Thread(ThreadStart);
     // allow UI with ApartmentState.STA though [STAThread] above should give that to you
     thread.TrySetApartmentState(ApartmentState.STA);
     thread.Start();
 }
开发者ID:Z6543,项目名称:Write-into-screen,代码行数:7,代码来源:write_into_screen.cs

示例2: Run

        public void Run()
        {
            //Start thread for UI
            var thread = new Thread(ThreadStart);
            thread.TrySetApartmentState(ApartmentState.STA);
            thread.Start();

            CreatePlayers();

            //Sets players in current game
            GenerateCurrPlayers();

            //врътка players
            GenerateCyclePlayers();


            dealer.FillDeck(database, cardFactory);
            dealer.Shuffle(database.Deck);
            dealer.DealCards(database.Deck, database.HumanPlayers, database.BotPlayers, database.TableCards);

            //Sets players power depending on their cards combinations
            SetPlayersPower();

            AddBlindsToPot();
        }
开发者ID:SavaIvanov9,项目名称:HQC---Team-Project---Papaya,代码行数:25,代码来源:Engine.cs

示例3: Main

        static void Main()
        {
            // Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //try
            //{
                Game game = new Game();
                GameForm gf;
                gf = new GameForm(game);
                Thread t = new Thread(new ParameterizedThreadStart(game.Start));
                t.Name = "GameLoop";
                t.IsBackground = true;
                t.TrySetApartmentState(ApartmentState.STA);
                t.Start(gf);

                //Thread tt = new Thread(new ThreadStart(gf.Show2));
                //tt.Start();
                gf.Init();
            //}
            //catch (Exception e) { MessageBox.Show(e.Message + e.InnerException + e.Source + e.StackTrace); }

            //if (t.ThreadState == ThreadState.Running)
             //   t.Abort();

            //Application.Run(new GameForm());
        }
开发者ID:DarkLotus,项目名称:TD,代码行数:26,代码来源:Program.cs

示例4: VisualizatorDomainAppl

 protected VisualizatorDomainAppl()
 {
     _thread = new Thread(WorkThread);
     if (!_thread.TrySetApartmentState(ApartmentState.STA))
         throw new Exception("Не удалось установить STA ApartmentState");
     _main = new InvisibleMainForm(this);
 }
开发者ID:AlexSneg,项目名称:VIRD-1.0,代码行数:7,代码来源:VisualizatorDomainAppl.cs

示例5: NetStateController

 public NetStateController()
 {
     recv = new NetStreamMultiReceiver(RTSConstants.MC_ADDR, RTSConstants.MC_GAME_PORT_MIN);
     tNet = new Thread(NetThread);
     tNet.Priority = ThreadPriority.BelowNormal;
     tNet.TrySetApartmentState(ApartmentState.MTA);
     tNet.IsBackground = true;
 }
开发者ID:RegrowthStudios,项目名称:VoxelRTS,代码行数:8,代码来源:NetStateController.cs

示例6: MessageLoop

        public MessageLoop()
        {
            thread = new Thread(threadLoop);
            thread.TrySetApartmentState(ApartmentState.STA);
            threadStarted = new TaskCompletionSource<bool>();

            thread.Start();

            threadStarted.Task.Wait();
        }
开发者ID:CyAScott,项目名称:MessageLoop,代码行数:10,代码来源:Program.cs

示例7: button3_Click

 // create package
 private void button3_Click(object sender, EventArgs e)
 {
     if (comboBox1.SelectedItem != null)
     {
         StartProcessing();
         thr = new Thread(new ParameterizedThreadStart(ProcessPackage));
         thr.TrySetApartmentState(ApartmentState.STA); // this fixes saveFileDialog exception
         thr.Start(comboBox1.SelectedItem);
     }
 }
开发者ID:plamikcho,项目名称:easyresx,代码行数:11,代码来源:Form1.cs

示例8: clientListUpdated

        public void clientListUpdated(long count)
        {
            if (controller == null)
                controller = ChatController.getController();

            Console.WriteLine("* New client list is ready, event is: " + count);

            Thread t = new Thread(() => controller.updateClientList(count));
            t.TrySetApartmentState(ApartmentState.STA);
            t.Start();
        }
开发者ID:jfhenriques,项目名称:tdin-chat-client,代码行数:11,代码来源:UserSubscribe.cs

示例9: Plotter

        public Plotter(string title, params Series[] s)
        {
            //new Plotter("Train", new FunctionSeries(Math.Cos, 0, 10, 0.1, "cos(x)"))
            Title = title;
            Series = s;
            InitializeComponent();

            var thread = new Thread(() => Application.Run(this));
            thread.TrySetApartmentState(ApartmentState.STA);
            thread.Start();
        }
开发者ID:benketriel,项目名称:sknn,代码行数:11,代码来源:Plotter.cs

示例10: Main

        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            var thread = new Thread(ThreadStart);
            // allow UI with ApartmentState.STA though [STAThread] above should give that to you
            thread.TrySetApartmentState(ApartmentState.STA);
            thread.Start(); 

            Application.Run(new GateIn());
        }
开发者ID:christandrian,项目名称:sampleApp,代码行数:11,代码来源:Program.cs

示例11: StartListenerThread

        private void StartListenerThread()
        {
            Trace.WriteLine("++WorkerRole.StartListenerThread", "Information");

            _listenerThread = null;
            _listenerThread = new Thread(TCPListener.TcpListenerProcess);
            _listenerThread.TrySetApartmentState(ApartmentState.STA);
            _listenerThread.Name = "Server TCP Listener";
            _listenerThread.Start();

            Trace.WriteLine("--WorkerRole.StartListenerThread", "Information");
        }
开发者ID:jonathanyeung,项目名称:ozwego,代码行数:12,代码来源:WorkerRole.cs

示例12: Start

		/// <summary>
		/// Open the 3D visualization in a exclusive thread in order to it do not create
		/// a conflict with the application thread
		/// </summary>        
		public static void Start()
		{
			// If there is already a thread, kill it
			if (_thread != null && _thread.IsAlive)
			{
				_thread.Abort();
			}

			// Start a new thread calling startMethod method
			_thread = new Thread(StartMethod);
			_thread.TrySetApartmentState(ApartmentState.MTA);
			_thread.Start();

			IsActive = true;
		}
开发者ID:intruder01,项目名称:20150105,代码行数:19,代码来源:Simulation3D.cs

示例13: KeepConntion

 /// <summary>
 /// 通过线程每隔一点时间刷数据库,保持连接
 /// </summary>
 public static void KeepConntion()
 {
     _thread = new Thread(LoopDual);
     _thread.Name = "KeepOracleConnection";
     _thread.IsBackground = true;
     // 设置线程状态为单线程
     try
     {
         _thread.TrySetApartmentState(ApartmentState.STA);
     }
     catch (Exception ex)
     {
         Logging.Write("KeepConntion 启动失败,线程设置出现错误,原因是:" + ex.ToString());
         return;
     }
     _thread.Start();
 }
开发者ID:civicacid,项目名称:myevo,代码行数:20,代码来源:OraData.cs

示例14: Main

        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            PXCMSession session = null;
            pxcmStatus sts = PXCMSession.CreateInstance(out session);
            if (sts >= pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                var thread = new Thread(ThreadStart);
                // allow UI with ApartmentState.STA though [STAThread] above should give that to you
                thread.TrySetApartmentState(ApartmentState.STA);
                thread.Start();

                Application.Run(new MainForm(session));
                session.Dispose();
            }
        }
开发者ID:hinmanj,项目名称:PORTABLE-INTELLIGENT-ENVIRONMENT,代码行数:18,代码来源:Program.cs

示例15: Loop

        //constructor
        public Loop(Main window, int targetUps, Boolean fpsLock, int maxFps)
        {
            //Console.WriteLine(window.GPanel.Visible);
            //stelt alle variablen in
            this.window = window;
            //window.GPanel.
            window.Paint += this.render;

            this.targetUps = targetUps;
            this.fpsLock = fpsLock;
            this.maxFps = maxFps;
            //intalizeerd het spel
            game = new Game(this);
            //initalizeerd de gameloop thraed en start hem op de methode init();
            t = new Thread(init);
            t.Priority = ThreadPriority.Highest;
            t.TrySetApartmentState(ApartmentState.MTA);
            t.Start();
        }
开发者ID:michieljanssen,项目名称:ICTSE1a4KBS1,代码行数:20,代码来源:Loop.cs


注:本文中的System.Threading.Thread.TrySetApartmentState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。