Handling WPF button double-click in MVVM pattern -


i have button in mvvm application hooked command in view model. handler view model command file i/o (particularly calling file.copy create or overwrite existing file).

now, seems when double-click on button, command handler gets called twice. since both handlers trying access same file copy/overwrite @ same time, i'm getting ioexception.

is there anyway deal situation short of catching ioexception , ignoring it? not seem guaranteed catch although there may unrelated problems rest of system causes happen.

use value in the viewmodel protect code running when click occurs. set value like: bool bfileio = false;

then in handler function:

 if (!bfileio)  {       bfileio = true;       //file io here        bfileio = false;  } 

something protect multi-clicking trying run multiple times.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -