0

I'm making a Telegram Bot using C# for "buying crypto". It doesn't actually buy it, just for practice When a client makes an order using "/buy" and fills all the blanks that are asked, it must tell the client "Please, wait. Your order is proceeding". In the real functional, it would really proceed the order, but in my case, it must do nothing in the range of 10 to 60 seconds and if the client types something, answer him something like "Your order is proceeding, it'd not take a lot"

The problem is, if i use

long time = new Random().NextInt64(10, 181);
Thread.Sleep(TimeSpan.FromSeconds(Convert.ToDouble(time)));

It will stop the bot and i won't be able to answer the client "Your order is proceeding, it'd not take a lot" in case the client types something while the thread is sleeping.

Here is an example what i mean Please wait, your order is proceeding i'm a client and i type some text when the order is proceeding Your order is proceeding, it'd not take a lot

What can i use to stop thread, but receive and handle the messages?

swipper.
  • 3
  • 3
  • Assuming this is already in an `async` method, you can just do `await Task.Wait(TimeSpan.FromSeconds(Convert.ToDouble(time)));` instead. Are you in an async method? – Sweeper Apr 05 '23 at 10:07
  • @Sweeper Yes, i'm using async. I'll let you know if this worked for me in several minutes – swipper. Apr 05 '23 at 10:11
  • @Sweeper can you show me an example how it must look like in code? – swipper. Apr 05 '23 at 10:56

0 Answers0