Every time I want a user to be able to drag a control, I call DoDragDrop of that control.
Drag and drop works fine, but I have a problem with things:
DoDragDrop completely blocks the form, timer events do not skip, messages with paint are processed.
DoDragDrop not only blocks the drag operation, but also until the target program finishes the drop event (IE error code explorer.exe suck). Depending on the other program code, sucks.
I thought to call DoDragDrop from a new thread.
tried this:
Thread dragThread = new Thread(() => { Form frm = new Form(); frm.DoDragDrop("data", DragDropEffects.All); }); dragThread.SetApartmentState(ApartmentState.STA); dragThread.IsBackground = true; dragThread.Start();
but it does not work. I mean: when executing DoDragDrop from another thread like this, other controls in my program or other programs do not receive drag and drop messages.
Any other solutions?
multithreading c # winforms drag-and-drop blocking
Dxck
source share