全球的asax公司
并在Application_Start()中调用它,当我启动project telegram bot时,它会正常工作,直到有一个用户,当第二个用户开始使用bot时,用户第二个用户更新不会产生另一个线程,并且它会在第一个用户进程的后续进程中工作!
例如:
用户#1以“AnswerForm”的形式发送消息(更新),以便bot通过第一个条件并等待用户在长轮询周期内输入表单Id,在这段时间内,当另一个用户启动bot并向其发送消息时,bot将其作为用户1表单Id接收!我猜想这会为他带来另一条线索,但我不知道我没有发生。那么我该如何解决这个问题呢?
static async void testApiAsync()
{
try
{
var Bot = new Telegram.Bot.TelegramBotClient("my_token");
var me = await Bot.GetMeAsync();
int offset = 0;
while (true)
{
var updates = await Bot.GetUpdatesAsync(offset);
foreach (var update in updates)
{
offset = update.Id + 1; //new offset id
if (update.Message != null)
{
if (update.Message.Text == "AnswerForm")
{
string askFormId = "send Form Id";
await Bot.SendTextMessageAsync(update.Message.Chat.Id, askFormId);
while (true)
{
//here was my code that
//wait for user to enter Form Id
}
}
}
}
}
}
catch { }
}