Management between buttons RRS feed

  • Question

  • If I have 2 buttons or more,each one does almost the same job ,but brings data from different place.
    These buttons take some time to connect to database, in this time if the user press on other button the execution of  whole app interrupted.
    So,How can I cut the execution of one of them(buttons) If the other button pressed?
    • Edited by GhadaNaim Friday, December 27, 2013 7:40 PM
    Friday, December 27, 2013 7:27 PM


All replies

  • You can disable the button (probably both of them) when you start the processed command and reenable it afterwards.

    How exactly you do this will depend on how you are implementing the buttons. If you're hooking up commands then this can be controlled by returning false from CanExecute when the action is pending.


    Friday, December 27, 2013 9:21 PM
  • Yes, thank you.
    I know this solution but I am searching for another solution,it can cut the old execution and start with new click.
    Is there another solution?
    Friday, December 27, 2013 10:49 PM
  • Do you mean you want to cancel the original task when the button's command fires?

    That will depend on how you launch the task. You can launch it with a cancellation token and then if the task supports cancellation the second command can request cancellation. If the task doesn't support cancellation then there isn't anything you can do.

    See Task(Action, CancellationToken).

    For more information and code examples see Cancellation in Managed Threads.

    • Marked as answer by Anne Jing Monday, January 6, 2014 9:46 AM
    Friday, December 27, 2013 10:59 PM
  • there are many options you can do.. create another two text button to show or hide those buttons by vissibility or you can disable them by the code

    if buffering




    Saturday, December 28, 2013 4:20 AM