Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public partial class MainWindow : Window
- {
- ......
- private RX consumer = new RX();
- private void Window_Loaded(object sender, RoutedEventArgs e)
- {
- try
- {
- Task backgroundDBTask = Task.Factory.StartNew(() => { Consumer(consumer);}, TaskCreationOptions.LongRunning);
- }
- }
- public void Consumer(Consumer consumer)
- {
- while (true)
- {
- Thread.Sleep(1000);
- .......
- Dispatcher.BeginInvoke(new Action(() =>
- {
- mylbl.Content = value.ToString();
- }), DispatcherPriority.Background);
- }
- }
- public partial class MainWindow : Window
- {
- ....
- private RX consumer = new RX();
- private void Window_Loaded(object sender, RoutedEventArgs e)
- {
- try
- {
- Task backgroundDBTask = Task.Factory.StartNew(() => { consumer.ProcessMessages(); }, TaskCreationOptions.LongRunning);
- }
- }
- }
- public class RX
- {
- public void ProcessMessages()
- {
- while (true)
- {
- Thread.Sleep(1000);
- ....
- var m_dispatcher = Application.Current.MainWindow;
- m_dispatcher.Dispatcher.BeginInvoke(new Action(() =>
- {
- mylbl.Content = value.ToString();
- }), DispatcherPriority.Background);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement