Check if x second passed, if not wait until x second
Im struggling a problem.This is for a trading bot, In an exchange, there is a rule. You can not trade after a trade, If you want to trade, you have to wait 5 seconds after first trade. After 5 seconds, trade is up to you, buy,sell or do nothing.
I have stopwatch and I call aFunction
, after end of the function, timer will start and I call bFunction
,if timer value < 5 seconds, It should wait until 5 seconds pass.
I make a while(true)
and I can check if(timer>5)
but it will eat cpu and if its single core it will be endless loop during 5 seconds.
Is there any c# way for this ? or any idea ? Sorry for my english and any help appreciated.
UPDATE
It shouldnt wait 5 seconds, if there is no trade before(5 seconds or more). So thread sleep or Timer doesnt work.
from Recent Questions - Stack Overflow https://ift.tt/3afxPYc
https://ift.tt/eA8V8J
Comments
Post a Comment