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


C# System.Threading.Thread.Join方法代码示例

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


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

示例1: StartHostAndClient_SimpleSyncMethodSyncCallWithAsync_Success

        public async void StartHostAndClient_SimpleSyncMethodSyncCallWithAsync_Success()
        {
            bool @continue = false;
            var thread = new System.Threading.Thread(() =>
            {
                using (var host = new WcfExampleServiceHost("localhost:10000"))
                {
                    host.Start();
                    @continue = true;
                    while (@continue)
                    {
                        System.Threading.Thread.Sleep(10);
                    }
                    host.Close();
                }
            });
            thread.Start();

            while ([email protected])
            {
                System.Threading.Thread.Sleep(10);
            }

            var client = new WcfExampleServiceAsyncClient("localhost:10000");
            SimpleSyncMethodResponseModel responseSimpleSyncMethod = client.SimpleSyncMethod(new SimpleSyncMethodRequestModel { Message = "Hello World" });
            Assert.IsNotNull(responseSimpleSyncMethod);
            Assert.AreEqual("SimpleSyncMethod: Hello World", responseSimpleSyncMethod.Message);

            @continue = false;

            thread.Join();
        }
开发者ID:CasperWollesen,项目名称:CW.Samples,代码行数:32,代码来源:WcfExampleServiceUnitTests.cs

示例2: 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();
            }
        }
开发者ID:saveenr,项目名称:saveenr,代码行数:25,代码来源:ClipboardUtilTest.cs

示例3: GetCubeLastSchemaUpdateDate

        public static DateTime GetCubeLastSchemaUpdateDate()
        {
            DateTime dtTemp = DateTime.MinValue;
            Exception exDelegate = null;

            string sServerName = Context.CurrentServerID;
            string sDatabaseName = Context.CurrentDatabaseName;
            string sCubeName = GetCurrentCubeName();

            System.Threading.Thread td = new System.Threading.Thread(delegate()
            {
                try {
                    Microsoft.AnalysisServices.Server oServer = new Microsoft.AnalysisServices.Server();
                    oServer.Connect("Data Source=" + sServerName);
                    Database db = oServer.Databases.GetByName(sDatabaseName);
                    Cube cube = db.Cubes.FindByName(sCubeName);

                    dtTemp = cube.LastSchemaUpdate;
                }
                catch (Exception ex)
                {
                    exDelegate = ex;
                }
            }
            );
            td.Start();
            while (!td.Join(1000))
            {
                Context.CheckCancelled();
            }

            if (exDelegate != null) throw exDelegate;

            return dtTemp;
        }
开发者ID:howtobi,项目名称:ASSP2,代码行数:35,代码来源:CubeInfo.cs

示例4: RunRepeatedly

 public void RunRepeatedly()
 {
     for (int i = 0; i < 5; i++)
     {
         System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(ThreadProc));
         t.Start();
         for (int k = 0; k < 10; k++)
         {
             System.Threading.Thread.Sleep(200);
             if (form != null && form.IsDisposed) break;
         }
         Console.WriteLine("Requesting close");
         for (int k = 10; k >= 0; k--)
         {
             form.CloseByExternalThread();
             t.Join(200);
             if (t.ThreadState == System.Threading.ThreadState.Stopped)
                 break;
             Console.WriteLine(""+t.ThreadState);
             if (k == 0)
                 throw new Exception("Form did not close when requested");
         }
         Console.WriteLine("Close complete");
     }
 }
开发者ID:adrianj,项目名称:Direct3D-Testing,代码行数:25,代码来源:RepeatabiliyTest.cs

示例5: SendNonQuery

 protected void SendNonQuery(string stmt)
 {
     var pts = new System.Threading.ParameterizedThreadStart(_SendNonQuery);
     System.Threading.Thread t = new System.Threading.Thread(pts);
     t.Start(stmt);
     t.Join();
 }
开发者ID:MindFlavor,项目名称:BackupToUrlWithRotation,代码行数:7,代码来源:DBUtil.cs

示例6: buttonLoadProfile_Click

 private void buttonLoadProfile_Click(object sender, EventArgs e)
 {
     System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(OpenLoad));
     t.Start();
     this.Hide();
     t.Join();
     this.Show();
 }
开发者ID:siracoj,项目名称:signtolearn,代码行数:8,代码来源:SignToLearn.cs

示例7: 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();
 }
开发者ID:Delnar,项目名称:TeenCheckin,代码行数:8,代码来源:frmException.cs

示例8: buttonTraining_Click

 private void buttonTraining_Click(object sender, EventArgs e)
 {
     System.Threading.Thread t = new System.Threading.Thread(() => StartTraining());
     t.Start();
     this.Hide();
     t.Join();
     this.Show();
 }
开发者ID:siracoj,项目名称:signtolearn,代码行数:8,代码来源:UserHomePage.cs

示例9: buttonConfirmLoadProfile_Click

 private void buttonConfirmLoadProfile_Click(object sender, EventArgs e)
 {
     String UserName = listBoxProfiles.SelectedItem.ToString();
     System.Threading.Thread t = new System.Threading.Thread(() => OpenProfile(UserName));
     t.Start();
     this.Hide();
     t.Join();
     this.Close();
 }
开发者ID:siracoj,项目名称:signtolearn,代码行数:9,代码来源:LoadProfile.cs

示例10: 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;
        }
开发者ID:cipjota,项目名称:Chronos,代码行数:10,代码来源:ConvertXps.cs

示例11: 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;
 }
开发者ID:truonghinh,项目名称:TnX,代码行数:10,代码来源:FrmImportDataFromXml.cs

示例12: Main

 public static int Main(string[] args)
 {
   int ret = 0;
   var thread = new System.Threading.Thread(
     new System.Threading.ThreadStart(() =>
       { ret = ThreadMain(args); }),
       0x10000000); // 256MB stack size to prevent stack overflow
   thread.Start();
   thread.Join();
   return ret;
 }
开发者ID:ggrov,项目名称:tacny,代码行数:11,代码来源:DafnyDriver.cs

示例13: Main

		public static void Main (string[] args) {
			String city;
			int days;
			int okresMin;
			int cityId;
			BackgroundTask bt1;
			System.Threading.Thread t1;
			String choice = "t";

			Console.WriteLine ("Program pobierajacy i analizujacy dane pogodowe pochodzace z serwisu openweathermap.org");	

			do {
				try {
					Console.Write ("\nProsze wpisac nazwe miasta (bez polskich znakow): ");
					city = Console.ReadLine();
					Console.Write ("Prosze wpisac liczbe dni, ktore ma obejmowac prognoza <1..16>: ");
					days = Int32.Parse(Console.ReadLine());
					Console.Write ("Prosze wpisac okres sprawdzania pogody [min]: ");
					okresMin = Int32.Parse(Console.ReadLine());
				} catch {
					Console.WriteLine ("Bledne dane"); continue;
				}

				try {
					cityId = getCityID (city, "../../dane/city.list.json"); // lista pobrana z http://bulk.openweathermap.org/sample/city.list.json.gz
				} catch {
					Console.WriteLine ("Nie znaleziono bazy miast w folderze /dane/city.list.json"); break;
				}

				if (cityId == 0) {
					Console.WriteLine ("Nie mozna znalezc miasta"); continue;
				}

				Console.WriteLine ("ID miasta to: " + cityId);
				Console.WriteLine ("Aby przerwac nacisnij enter...");
				Console.WriteLine ();

				bt1 = new BackgroundTask(cityId, days, okresMin);
				t1 = new System.Threading.Thread(new System.Threading.ThreadStart(bt1.keepChecking));
				t1.Start();

				//while (!t1.IsAlive);
				Console.ReadLine();


				Console.WriteLine ("Czy powtorzyc program dla innych kryteriow? [t/n]");
				choice = Console.ReadLine();
				t1.Abort (); t1.Join ();
			} while (choice.ToLower().Equals("t"));

			Console.WriteLine ("Koniec programu.");
		}
开发者ID:michal2229,项目名称:cs-json-dane-pogodowe-openweathermap,代码行数:52,代码来源:Program.cs

示例14: Click

 public void Click(bool mayPopupDlg)
 {
     //If it may popup a dialog to block the execution of current thread, we need to 
     // try clicking in a seperate thread.
     if (mayPopupDlg)
     {
         System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(Click));
         t.Priority = System.Threading.ThreadPriority.Highest;
         t.Start();
         t.Join(1000);
     }
     else
     {
         Click();
     }
 }
开发者ID:a19284,项目名称:SmartUI,代码行数:16,代码来源:SUIHtmlControlBase.cs

示例15: Start

        /// <summary>
        /// Implement start method from base class to be called from form and start threads.
        /// </summary>
        public override void Start()
        {
            threadSearch = new System.Threading.Thread(SearchImage);
            threadSearch.Start();

            threadMove = new System.Threading.Thread(SetFiniteStateMachine);
            threadMove.Start();

            while (running && connected)
            {
               // System.Threading.Thread.Sleep(1000);
            }

            threadSearch.Join();
            threadMove.Join();
        }
开发者ID:jblakeLincoln,项目名称:Rovio,代码行数:19,代码来源:PredatorSimple.cs


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