c# - Return bool from a Background thread in WPF -


public bool function() {     bool doesexist = false;               backgroundworker worker = new backgroundworker();     worker.dowork += (o, ea) =>         {             // work done here         };      worker.runworkercompleted += (o, ea) =>         {             //somw logic here             return doesexist;                                        }; }  

i want doesexist value return value function getting intellisense error

system.componentmodel. runworkercompletedeventhandler returns void, return keyword must not followed object expression

why getting error, how return bool value?

public bool function() {    bool doesexist = false;              backgroundworker worker = new backgroundworker();     worker.dowork += (o, ea) =>             {                  // work                  ea.result = true; // set true if goes well!             };      worker.runworkercompleted += (o, ea) =>         {               // since boolean value calculated here &               // runworkercompleted returns void               // can create method boolean parameter handle result.               another_way_to_return_boolean(doesexist)           }; }    private void another_way_to_return_boolean(bool result) {     if (result)     {      } } 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -