title: How to Access object created in System.Timers.Timer in a GUI Event
body: <p>I'm using a <code>System.Timers.Timer</code> to get a <code>PrintQueueCollection</code> every N-seconds so I'm always up to date if something changed. The timer sends a <code>RefreshEvent</code> with the PrintQueue so I can handle changes in my Gui.</p>
  
  <p>Here's the Refresh function, the timer calls every n-seconds</p>
  
  <pre><code>private void Refresh()
  {
      lock (_locker)
      {
          try
          {
               // _server == ServerName if isNullOrEmppty it's localhost
              PrintServer printServer = new PrintServer(_server);
              PrintQueueCollection printQueueCollection = printServer.GetPrintQueues();
  
              foreach (PrintQueue pq in printQueueCollection)
              {
                  if (_firstRun) break;
  
                  // List of Unique Printernames so not all printers get 'refreshed'
                  if (_printersToMonitor.Contains(pq.Name))
                  {
                      var currentPrinter = new Printer(pq);
                      // Event catched in Gui
                      Refreshed?.Invoke(currentPrinter);
                  }
              }
          }
          catch (Exception)
          {
              //...
          }
      }
  }
  </code></pre>
  
  <p>The Event is catched in a Control this way</p>
  
  <pre><code>// Printer is a Wrapper class that contains the PrintQueue and several other information I need e.g. results of SNMP walks
  private void RefreshPrinter(Printer printer)
  {
      if (_localPrinters.Count == 0)
          Dispatcher.Invoke(() =&gt; _localPrinters.Add(printer));
      else
      {
          // _localPrinters is a ObservableCollection&lt;Printer&gt; Bound to gui
          foreach (Printer p in _localPrinters.ToList())
          {
              if (p.FullName == printer.FullName)
              {
                  p.NumberOfJobs = printer.NumberOfJobs;
                  p.Status = printer.Status;
                  return;
              }
          }
          Dispatcher.Invoke(() =&gt; _localPrinters.Add(printer));
      }
  }
  </code></pre>
  
  <p>So far so good now comes the point I don't know how to handle. The <code>ObservableCollection&lt;Printer&gt;</code> is bound to a <code>DataGrid</code> were all general information is Displayed. Now if a user double clicks a Row, I want to show some 'deeper' information in a userControl. But I can't find a way to access the <code>PrintQueue</code> here because it's the wrong Thread.</p>
  
  <pre><code>private void Row_DoubleClick(object sender, MouseButtonEventArgs e)
  {
      // Printer is fine, just the PrintQueue inside is full of System.InvalidOperationException
      Printer p = (sender as DataGridRow)?.DataContext as Printer;
      UcPrinterDetails.InitializeDetails(p.PrintQueue);
  
      UcPrinterDetails.Visibility = UcPrinterDetails.Visibility != Visibility.Visible ? Visibility.Visible : Visibility.Collapsed;
  }
  </code></pre>
  
  <p>So my question here: What is the best way to access the PrintQueue object and which Thread is the owner of the object?</p>