The code looks like this
var from = DateTime.Now.AddDays(-30); var barsRequest = new BarsRequest(Instrument, from, DateTime.Now); barsRequest.Request( (bars, errorCode, errorMessage) => { // do some stuff here // barsRequest no longer needed so clean it up. Checking for null is pointless as we won't get in here if its not created barsRequest.Dispose(); }); barsRequest.Dispose(); // Not safe because Request may still be executing, if it executes asynchronously?
I have a few questions.
- Is it safe to do this? Because Request hasn't finished and barsRequest object will be disposed this would be bad?
- Does Request execute asynchronously? I have not tested this but I guessed that it executes on some other thread, whenever the request has completed.
Comment