My application uses ICommand
s to bind methods to Buttons.
I initialized these commands as follows :
AnswerCommand = new DelegateCommand(AnsCommandExecute, AnsCommandCanExecute);
I want to know ifAnsCommandExecute()
method will work on UI thread or Background thread?
If it works on UI thread do I have to create another thread for this execute() method as my application performs lot of processing in background.
Also my application uses TCP to communicate with one another application. so, for better performance Do I have to use different threads for Receiving Data, Processing, and Sending Data. what will be the best Threading approach for such applications?
Simplest way to find whether AnsCommandExecute()
method works on main thread or not is to put break point in the method and check call stack.
Quick answer is yes - AnsCommandExecute()
will execute on main thread.
To answer your threading requirement, you can invoke content inside AnsCommandExecute()
on separate thread. This will make UI responsive.
If you are going to receive responses asynchronously, you then have to move operation back to main thread with help of "Dispatcher". More also at the Dispatcher documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With