c# - DragDrop.DoDragDrop froze DispatcherTimer -


i have wpf application dispatchertimer in ui thread.

    private int timelimit = 500;     private dispatchertimer _timer;      public mainwindow()     {         _timer = new dispatchertimer { interval = timespan.frommilliseconds(timelimit) };         _timer.tick += timertick;         _timer.start();         initializecomponent();     }     private void timertick(object sender, eventargs e)     {         system.diagnostics.debug.writeline(datetime.now.tostring("hh:mm:ss.fff") + " timer");     } 

and when hover button, implement drag logic, dispatchertimer holding.

xaml:

<button width="200" height="50" content="test"   previewmousemove="_mousemove"/> 

code:

        private point startpoint = new point();         private void _mousemove(object sender, mouseeventargs e)         {             system.diagnostics.debug.writeline(datetime.now.tostring("hh:mm:ss.fff") + " mouseposition");              // current mouse position             point mousepos = e.getposition(null);             vector diff = startpoint - mousepos;         if (e.leftbutton == mousebuttonstate.pressed &&             math.abs(diff.x) > systemparameters.minimumhorizontaldragdistance ||             math.abs(diff.y) > systemparameters.minimumverticaldragdistance)         {             // dragged item             button item = sender button;             if (item != null)             {                 // data                 string contact = (string)item.content;                  // initialize drag & drop operation                 dataobject dragdata = new dataobject("string", contact);                 dragdrop.dodragdrop(item, dragdata, dragdropeffects.move);             }         }     }  

i must use working dispatchertimer. how can make friends dodragdrop , dispatchertimer?


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

python - No response in ssh.exec_command in paramiko -