var mrse = new ManualResetEvent(false);
public void Run()
{
while (true)
{
mrse.WaitOne();
printMessageOnGui("Hey");
Thread.Sleep(2000); . .
}
}
public void Resume() => mrse.Set();
public void Pause() => mrse.Reset();
More Related Contents:
- The calling thread cannot access this object because a different thread owns it
- How do I update an ObservableCollection via a worker thread?
- Question about terminating a thread cleanly in .NET
- Trying to run multiple HTTP requests in parallel, but being limited by Windows (registry)
- catch exception that is thrown in different thread
- What is the difference between await Task and Task.Result?
- Updating GUI (WPF) using a different thread
- ‘using’ statement vs ‘try finally’
- Thread.Sleep for less than 1 millisecond
- Is Task.Factory.StartNew() guaranteed to use another thread than the calling thread?
- What is the impact of Thread.Sleep(1) in C#?
- Can I serialize nested properties to my class in one operation with Json.net?
- The current SynchronizationContext may not be used as a TaskScheduler
- STAThread and multithreading
- Spawn Multiple Threads for work then wait until all finished
- c# working with Entity Framework in a multi threaded server
- How to terminate a thread in C#?
- Thread safe collections in .NET
- Why CancellationToken is separate from CancellationTokenSource?
- How to correctly read an Interlocked.Increment’ed int field?
- Async WebApi Thread.CurrentCulture
- Is it safe to use a boolean flag to stop a thread from running in C#
- ConcurrentDictionary Pitfall – Are delegates factories from GetOrAdd and AddOrUpdate synchronized?
- Thread safety on readonly static field initialisation
- Synchronous implementation of interface that returns Task
- C# and thread-safety of a bool
- Populating a DataGridView with Text and ProgressBars
- How to properly parallelise job heavily relying on I/O
- Does MessageBox.Show() automatically marshall to the UI Thread?
- Calling an async method from a synchronous method