c# - ServiceHost.BeginOpen blocks the caller thread -
i use servicehost in wpf application. when call servicehost.open method takes 30 seconds complete (i connect azure servicebus. long wait time seems come our company internet proxy).
because takes long call not block dispatcher thread , should support cancellation. unfortunately, servicehost not support task api easy create one:
public static class communicationobjectextensions { public static task openasync(this communicationobject co, cancellationtoken token) { token.register(() => co.abort()); return task.factory.fromasync(co.beginopen(null, null), co.endopen); } } why servicehost.beginopen call block dispatcher thread? msdn documentation says beginopen done asynchronously. way dispatcher thread should not blocked.
Comments
Post a Comment