本文整理汇总了C#中ThreadStart类的典型用法代码示例。如果您正苦于以下问题:C# ThreadStart类的具体用法?C# ThreadStart怎么用?C# ThreadStart使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ThreadStart类属于命名空间,在下文中一共展示了ThreadStart类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: MainForm
public MainForm()
{
InitializeComponent();
m_settings = new Settings();
LoadSettings();
// default is HS if not selected
m_stripHS = new Hesari(HS_BASE_ADDRESS);
m_stripKaleva = new Kaleva(KALEVA_BASE_ADDRESS);
if (m_settings.SourceSelection == SelectedSource.HS ||
m_settings.SourceSelection == SelectedSource.NOT_SELECTED)
m_currentStrip = m_stripHS;
else
m_currentStrip = m_stripKaleva;
//Prepare the fade in/out threads that will be called later
ThreadStart fadeInStart = new ThreadStart(FadeIn);
m_fadeIn = new Thread(fadeInStart);
ThreadStart fadeOutStart = new ThreadStart(FadeOut);
m_fadeOut = new Thread(fadeOutStart);
loadResources();
nextPictureBox.Hide();
prevPictureBox.Hide();
this.MouseClick += new MouseEventHandler(MainForm_MouseClick);
ResizeRedraw = true;
SetLoadLabel(true);
LoadCurrent();
}
开发者ID:juusimaa,项目名称:WinFingerpori,代码行数:35,代码来源:MainForm.cs
示例2: LoaderMgr
public LoaderMgr(LoadFunction Function)
{
_Function = Function;
ThreadStart Start = new ThreadStart(Load);
Thread LoadThread = new Thread(Start);
LoadThread.Start();
}
开发者ID:Novo,项目名称:apbprivateserver,代码行数:7,代码来源:LoaderMgr.cs
示例3: StartThread
public void StartThread()
{
ThreadStart threadStart = new ThreadStart(UpdateIndex);
Thread thread = new Thread(threadStart);
thread.IsBackground = true;//后台线程
thread.Start();
}
开发者ID:zhangkangen,项目名称:Learn,代码行数:7,代码来源:IndexQueue.cs
示例4: btnTrain_Click
private void btnTrain_Click(object sender, EventArgs e)
{
this.status.Text = "Training...";
ThreadStart ts = new ThreadStart(ThreadProc);
Thread thread = new Thread(ts);
thread.Start();
}
开发者ID:DoctorBoo,项目名称:ML,代码行数:7,代码来源:PruneSelectivelForm.cs
示例5: MainApp
public MainApp(bool passed_debug_mode, string passed_version, bool passed_verbose)
{
//This checks if there is a new version, and if so alerts user
ThreadStart update_Checker = new ThreadStart(this.check_updates_wrapper);
Thread new_thread = new Thread(update_Checker);
new_thread.Name = "6 to 4 - Update Checker";
new_thread.Start();
//Start the actual window
InitializeComponent();
//Tell all threads, amin is still running, is janky but works
running = 2;
//Starts animating icon while devcon is running
ThreadStart Animation = new ThreadStart(this.animation);
Thread animation_thread = new Thread(Animation);
animation_thread.Name = "6 to 4 - Animation Thread";
animation_thread.Start();
//Set internals from passed
internal_version = passed_version;
internal_debug = passed_debug_mode;
internal_verbose = passed_verbose;
//Easter egg
if (internal_verbose == true)
{
FLASHY = new Visual_Form();
verbose_wrapper();
}
}
开发者ID:daberkow,项目名称:6to4-Card-Cleaner,代码行数:28,代码来源:MainApp.cs
示例6: Main
static void Main(string[] args)
{
try
{
// Using Spring's IoC container
ContextRegistry.GetContext();
Spring.Messaging.Amqp.Rabbit.Listener.SimpleMessageListenerContainer container =
ContextRegistry.GetContext().GetObject("MessageListenerContainer") as Spring.Messaging.Amqp.Rabbit.Listener.SimpleMessageListenerContainer;
container.Start();
Console.Out.WriteLine("Server listening...");
IMarketDataService marketDataService =
ContextRegistry.GetContext().GetObject("MarketDataGateway") as MarketDataServiceGateway;
ThreadStart job = new ThreadStart(marketDataService.SendMarketData);
Thread thread = new Thread(job);
thread.Start();
Console.Out.WriteLine("--- Press <return> to quit ---");
Console.ReadLine();
}
catch (Exception e)
{
Console.Out.WriteLine(e);
Console.Out.WriteLine("--- Press <return> to quit ---");
Console.ReadLine();
}
}
开发者ID:DonMcRae,项目名称:spring-net-amqp,代码行数:27,代码来源:Program.cs
示例7: Run
private void Run(ThreadStart userDelegate, ApartmentState apartmentState)
{
lastException = null;
Thread thread = new Thread(
delegate()
{
#if !DEBUG
try
{
#endif
userDelegate.Invoke();
#if !DEBUG
}
catch (Exception e)
{
lastException = e;
}
#endif
});
thread.SetApartmentState(apartmentState);
thread.Start();
thread.Join();
if (ExceptionWasThrown())
ThrowExceptionPreservingStack(lastException);
}
开发者ID:sivarajankumar,项目名称:dentalsmile,代码行数:28,代码来源:CrossThreadTestRunner.cs
示例8: Main
public static void Main(string[] args)
{
Console.WriteLine ("Starting up websocket...");
Thread thread = null;
WebsocketController ws = new WebsocketController ();
ws.Setup ("ws://websocket.org", "80", "/echo", "echo.websocket.org");
ThreadStart ts = new ThreadStart (() => {
ws.Connect ((str) => {
Console.WriteLine ("OPEN");
ws.Send ("Message 1");
}, (str2) => {
Console.WriteLine ("Received");
//ws.Send ("Message n");
}, (str3)=>{ Console.WriteLine(str3); if(thread != null) thread.Join();},
(str4)=>{ Console.WriteLine(str4); if(thread != null) thread.Join();});
});
thread = new Thread (ts);
thread.Start ();
while (true) {
string s = Console.ReadLine ();
if (!string.IsNullOrEmpty (s))
ws.Send (s);
}
}
开发者ID:jonghough,项目名称:TekitouSockets,代码行数:25,代码来源:Program.cs
示例9: RTSPClient
//creates new client object
public RTSPClient(Socket connectedFrom, string name)
{
try
{
//initialize socket client communicating through
clientSkt = connectedFrom;
//intialize stream with new socket
ntwkstrm = new NetworkStream(clientSkt);
//create delegate for runClient method
ThreadStart runClientMethod = new ThreadStart(this.runClient);
//initialize thread to run runClient
clientThread = new Thread(runClientMethod);
clientThread.Name = name;
//start the thread
clientThread.Start();
}
catch (ThreadStartException tse)
{
//if thread could not be started notify view
referenceToView.Invoke(referenceToView.changeServerStatusTextBox, ("Thread start exception in RTSPClient constructor: "+tse.ToString()));
}
catch (Exception e)
{
//if any other exception occured notify view
referenceToView.Invoke(referenceToView.changeServerStatusTextBox, ("Exception in RTSPClient constructor: "+e.ToString()));
}
}
开发者ID:PresCoke,项目名称:Network-Video-Player,代码行数:29,代码来源:RTSPClient.cs
示例10: Execute
public void Execute(IWorker[] workers, int runningSecs)
{
IAsyncResult[] ar = new IAsyncResult[workers.Length];
int i = 0;
foreach (IWorker w in workers) {
w.WorkerID = i;
ThreadStart t = new ThreadStart(w.DoWork);
ar[i++] = t.BeginInvoke(null, null);
}
//for (int j = 0; j < runningSecs * 10; j++)
//{
// Console.Write(".");
// Thread.Sleep(100);
//}
Thread.Sleep(runningSecs * 1000);
Console.WriteLine();
foreach (IWorker w in workers) {
w.Running = false;
}
bool timeOut = false;
foreach (IAsyncResult a in ar) {
if (!a.IsCompleted)
{
if (!a.AsyncWaitHandle.WaitOne(1000))
timeOut = true;
}
}
if (timeOut)
Console.WriteLine("Timed Out!");
}
开发者ID:AveProjVstm,项目名称:MonoVstmTests,代码行数:32,代码来源:ExecutorThreadPool.cs
示例11: act
public void act(Body bodyIn)
{
body = bodyIn;
ThreadStart act = new ThreadStart (CallToActThread);
Thread ActThread = new Thread (act);
ActThread.Start ();
}
开发者ID:uagnd,项目名称:S-BPM_VR,代码行数:7,代码来源:Person.cs
示例12: Enqueue
/// <summary> add jobs to the queue. </summary>
/// <param name="jobs"> should be one or more pairs. </param>
public virtual void Enqueue(ThreadStart[] jobs)
{
lock (toDo) {
foreach (var job in jobs) toDo.Enqueue(job);
if (worker == null) Run();
}
}
开发者ID:AlexMaskovyak,项目名称:rit-4005-714-maskovyak-pecoraro,代码行数:9,代码来源:WorkQueue.cs
示例13: Run
public void Run(string fileName, string arguments)
{
if (isRunning) throw new Exception("This ProcessRunner is already running a process.");
if (!File.Exists(fileName)) throw new FileNotFoundException("The program '"+fileName+"' was not found.",fileName);
isRunning = true;
process = new Process();
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.FileName = fileName;
process.StartInfo.Arguments = arguments;
process.StartInfo.WorkingDirectory = Environment.CurrentDirectory;
process.Start();
outputReader = process.StandardOutput;
errorReader = process.StandardError;
// we need to wait for all 3 of our threadpool operations to finish
// (processexit, readoutput, readerror)
tasksFinished = 0;
// do our waiting on the threadpool
ThreadStart waitForExitDel = new ThreadStart(process.WaitForExit);
waitForExitDel.BeginInvoke(new AsyncCallback(TaskFinished),null);
// also read outputs on the threadpool
ThreadStart readOutputDel = new ThreadStart(ReadOutput);
ThreadStart readErrorDel = new ThreadStart(ReadError);
readOutputDel.BeginInvoke(new AsyncCallback(TaskFinished),null);
readErrorDel.BeginInvoke(new AsyncCallback(TaskFinished),null);
}
开发者ID:heon21st,项目名称:flashdevelop,代码行数:34,代码来源:ProcessRunner.cs
示例14: StressTest
public void StressTest()
{
queue = new ProducerConsumerQueue();
ThreadStart consumerMethod = new ThreadStart(accumulatingRunner);
Thread consumerThread = new Thread(consumerMethod);
consumerThread.Start();
Thread.Sleep(500);
ArrayList threads = new ArrayList();
for (int i = 0; i < 100; i++)
{
ThreadStart producerMethod = new ThreadStart(producingThread);
threads.Add(new Thread(producerMethod));
}
for (int i = 0; i < 100; i++)
{
((Thread)threads[i]).Start();
}
for (int i = 0; i < 100; i++)
{
((Thread)threads[i]).Join();
}
consumerThread.Join();
Assert.AreEqual(0, queue.Count);
Assert.AreEqual(100000, staticCounter);
for (int i = 0; i < 100000; i++)
{
Assert.AreEqual(i, (int)accumulatedResults[i], "Failed at index " + i);
}
}
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:35,代码来源:ProducerConsumerQueueFixture.cs
示例15: Main
static void Main(string[] args)
{
Program PC = new Program();
ThreadStart TS = new ThreadStart(PC.ShowTime);
Thread t = new Thread(TS);
t.Start(); Console.ReadLine();
}
开发者ID:dbdipannita,项目名称:Clock,代码行数:7,代码来源:clock.cs
示例16: MessageHandler
// Receive in a seperate thread
public MessageHandler(MainGrid active_grid)
{
c = Communicator.GetInstance(active_grid);
ThreadStart ts = new ThreadStart(c.ReceiveData);
Thread t = new Thread(ts,50000000);
t.Start();
}
开发者ID:anuradhawick,项目名称:NukeIt-Tanker-Game,代码行数:8,代码来源:MessageHandler.cs
示例17: Main
static void Main()
{
Program p = new Program();
Calculator c = new Calculator();
// Get first numeric value.
c.FirstNumber = p.GetNumericValue();
// Get second numeric value.
c.SecondNumber = p.GetNumericValue();
// TODO: Create an instance of the ThreadStart delegate passing
// in the Add method of the Calculator class.
ThreadStart threadStart = new ThreadStart(c.Add);
// TODO: Declare and create an instance of the secondary thread
// passing in the delegate instance.
Thread thread = new Thread(threadStart);
//TODO: Start the secondary thread.
thread.Start();
System.Threading.Thread.Sleep(2500);
Console.WriteLine("\nTotal values: {0}",
c.TotalValue);
Console.Write("\nPress any key to end.");
Console.ReadLine();
}
开发者ID:Meowse,项目名称:student1,代码行数:30,代码来源:Program.cs
示例18: FileImageLoader
public FileImageLoader()
{
ThreadStart threadStart = new ThreadStart(ThreadProc);
workerThread = new Thread(threadStart);
workerThread.IsBackground = true;
workerThread.Start();
}
开发者ID:helgihaf,项目名称:SimpleSearch,代码行数:7,代码来源:FileImageLoader.cs
示例19: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
try
{
Session["MainUrl"].ToString();
}
catch (NullReferenceException)
{
Response.Redirect("~/");
return;
}
Debug.WriteLine(">>>> CodeQuality");
this.sitemap = (List<string>)Session["selectedSites"];
var ths = new ThreadStart(TestCodeQuality);
var th = new Thread(ths);
th.Start();
th.Join();
var sb = new System.Text.StringBuilder();
CodeQualitySession.RenderControl(new System.Web.UI.HtmlTextWriter(new System.IO.StringWriter(sb)));
string htmlstring = sb.ToString();
Session["CodeQuality"] = htmlstring;
}
开发者ID:Peacefield,项目名称:DotsolutionsWebsiteTester,代码行数:27,代码来源:CodeQuality.aspx.cs
示例20: Main
static void Main(string[] args)
{
ThreadSample sample = new ThreadSample();
ThreadStart tsa = new ThreadStart(sample.ThreadFuncA);
ThreadStart tsb = new ThreadStart(sample.ThreadFuncB);
Thread ta = new Thread(tsa);
Thread tb = new Thread(tsb);
// A 线程的 优先级 高于 B 线程
// 在线程代码的 计数 中,A线程的 数值要大于 B线程。
ta.Priority = ThreadPriority.Highest;
tb.Priority = ThreadPriority.Lowest;
// 启动.
ta.Start();
tb.Start();
// 执行5秒以后, 结束
Thread.Sleep(5000);
ta.Abort();
tb.Abort();
Console.ReadLine();
}
开发者ID:mahuidong,项目名称:my-csharp-sample,代码行数:33,代码来源:Program.cs
注:本文中的ThreadStart类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论