c# - Cross GUI Thread Drag Drop operation -
i have application 3 forms. 2 of forms have grid controls running on separate gui threads. understand running separate gui threads not norm performance requirements forcing me adopt path. third form has set of items in listview box can dragged , dropped on other 2 forms.the problem i'm having implementing drag/drop functionality. had application running on single gui thread , drag/drop worked fine then. since separating them out, i'm having issues cross thread operation. here sample of code.
private void grid1_dragdropcontent(object sender, dragdropcontenteventargs e) { if (e.content == null) { if (e.data.getdatapresent(typeof(listview.selectedlistviewitemcollection))) { e.effect = dragdropeffects.copy; listview.selectedlistviewitemcollection items = e.data.getdata(typeof(listview.selectedlistviewitemcollection)) listview.selectedlistviewitemcollection; // code breaks here foreach (listviewitem item in items) { ...... } } } }
i exception when trying access each of listviewitems since created on different thread. know cross thread operations resolved using invoke , i'm unsure on how use here since selectedlistviewitemcollection not give me access underlying listview. there anyway resolve issue ? appreciated.
thanks.
Comments
Post a Comment