Skip to content

Instantly share code, notes, and snippets.

@mrtank
Last active April 7, 2020 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrtank/d14a354f4835502267a1ba347b34842a to your computer and use it in GitHub Desktop.
Save mrtank/d14a354f4835502267a1ba347b34842a to your computer and use it in GitHub Desktop.
while (!quit)
{
var uiThreadScheduler = TaskScheduler.FromCurrentSynchronizationContext();
Task<decimal> backgroundTask = Task.Run (() => {
var lastPrice = (decimal)NTClient.MarketData(inst, 0);
Interlocked.Increment(ref this.theCounter);
return lastPrice;
};
backgroundTask.ContinueWith((t) => {
<handle t.IsFaulter>
textBoxLastPrice.Text = t.Result.ToString();
tbBoundaryPrice.Text = boundaryPrice.ToString();
investmentTypeBox.Text = investmentType;
positionSizeBox.Text = positionCounter.ToString();
tbsboundaryPrice.Text = sboundaryPrice.ToString();
debugBox.Text = theCounter.ToString();
}, uiThreadScheduler);
Run4(NTClient); // same logic in there.
Run5(NTClient); // same logic in there.
}//while.... end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment