c# - Event's action performed on new thread -
i have observable collection
var querylist = new observablecollection<querydata>();
suppose have implemented method onquerylistcollectionchanged when collection's collectionchanged event triggered. trick method execute on new thread.
querylist.collectionchanged += new system.collections.specialized.notifycollectionchangedeventhandler(new threadstart(onquerylistcollectionchanged));
i know line above incorrect not sure how have collection's notifycollectionchangedeventhandler delegate point method onquerylistcollectionchanged new thread.
any appreciated.
thanks.
there's no direct means of having events handled on separate thread registering of handler.
you point event method , spawn new thread there work, yes, event being raised may interrupt main thread, long enough start new thread.
as side note, i'd recommend against using threads directly , instead making use of newer task
classes, see: what difference between task , thread?
Comments
Post a Comment