mathpaquette / IQFeed.CSharpApiClient

IQFeed.CSharpApiClient is fastest and the most well-designed C# DTN IQFeed socket API connector available
MIT License
120 stars 43 forks source link

Add more async methods #68

Closed summatix closed 3 years ago

summatix commented 4 years ago

Added a few extra async methods. I've been using these in my fork to prevent blocking async code.

mathpaquette commented 4 years ago

to be honest, I dont really get the value of these methods..

mathpaquette commented 4 years ago

@Nucs what do you think? Personally, if we're thinking to have both, I mean async and sync, we should think of replacing the sync implementation by the calling the async impl using the SynchronouslyAwaitTaskResult extension method.

summatix commented 4 years ago

to be honest, I dont really get the value of these methods..

SocketClient(IPAddress host, int port, int bufferSize = 8192), DerivativeClient<double> CreateNew(IPAddress host, int port), DerivativeClient<double> CreateNew(IPAddress host, int port, int bufferSize), DerivativeClient<T> CreateNew<T>(IPAddress host, int port, int bufferSize, IDerivativeMessageHandler<T> derivativeMessageHandler) — because I want to connect directly to an IP instead of a domain. The current code throws an exception if the given host isn't resolvable via a DNS query. I'd also be open to changing the existing methods to handle either an IP or a domain rather than adding methods specifically for IPs, but this was quicker for me to get working.

ConnectAsync, DisconnectAsync, SendAsync, ReqBarWatchAsync, UnwatchAllAsync — because I want to call from async code without blocking.

ReqBarUnwatch(string symbol), ReqBarUnwatchAsync(string symbol), ReqBarUnwatchAsync(string symbol, string requestId) — because I want to be able to unwatch an individual symbol rather than unwatch everything.

Personally, if we're thinking to have both, I mean async and sync, we should think of replacing the sync implementation by the calling the async impl using the SynchronouslyAwaitTaskResult extension method.

I think this is a good idea.

Nucs commented 4 years ago

@mathpaquette Other than the last review, seems good.

summatix commented 4 years ago

I accidentally merged other branches I'm working on which is why the last CI build failed. The force pushes are from the rebases I did unmerging the branches. CI is passing again.