本文整理汇总了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();
}
示例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();
}
}
示例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;
}
示例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");
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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.");
}
示例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();
}
}
示例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();
}