+ Reply to Thread
Results 1 to 2 of 2

Thread: Reading Control status from another thread

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    14

    Reading Control status from another thread

    I`d like to read the status of my Checkbox from another thread.
    I tried :
    Code:
    bool? isSleep = checkBoxSleep.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate{ return checkBoxSleep.IsChecked;})
    But that didn`t work.

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    45
    Your code will not compile because, whilst you are attempting to return a bool? from your delegate, ThreadStart has a return type of void.
    If you want this to work , please check my code :
    Code:
    bool? isSleep = null;
    checkBoxSleep.Dispatcher.Invoke(new Action(() =>
    { 
        isSleep = checkBoxSleep.IsChecked; 
    }), 
        DispatcherPriority.Normal);

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts