c# - Dispose RX Threads on application exit -
i stuck @ correctly disposing threads, created rx, on application exiting. see in process explorer after application closed, threads still running, causing io exceptions.
class program { static void main(string[] args) { compositedisposable subsriptions = new compositedisposable(); subscriptions.add(observable.interval(timespan.fromseconds(15)) .subscribe(_ => { getdata(); })); thread.sleep(timespan.fromseconds(20)); subscriptions.dispose(); } } }
if see if uncomment subscription.dispose(), thread terminates without getting data. appreciated. thanks
you need sort of delay between subsriptions.add(...)
, subscriptions.dispose()
. without delay between there, app subscribing , disposing them immediately, no time threads work. (and thread.sleep(1000)
doesn't work, since inside subscription function, not part of main function.)
Comments
Post a Comment