Hi guys
I want to run async method as a ScheduleTask in my plugin.
Public class DataPollingTask: ITask { Private static readonly BotClient Bot = new BotClient (); Public void Execute (TaskExecutionContext ctx) { Bot.OnMessage + = BotOnMessageReceived; Var me = Bot.GetMeAsync (). Bot.StartReceiving (); } Private static async void BotOnMessageReceived (object sender, MessageEventArgs messageEventArgs) { // code ... } // other code ... }
But occurred an error (on this page: Admin / ScheduleTask / List):
"Asynchronous operations asynchronous operations can only be used in an asynchronous handler." If this exception occurs while executing a page, make sure the page is tagged <% @ Page Async = "true"%>. This is an ASP.NET requestprocessing.This is an ASP.NET requestprocessing instead, the asynchronous method should return a task, and the caller should wait for it. "
Bot.StartReceiving () is a listener. Bot.StartReceiving () is work in ConsoleProject but I want to use my listener in SmartStore plugin. Plz help and tell me the right way for this purpose.