TS3AudioBot icon indicating copy to clipboard operation
TS3AudioBot copied to clipboard

Async events are no longer possible

Open MoroseCorpse opened this issue 4 years ago • 0 comments

Describe the bug I want to call the function ClientDbInfo(). Since this runs asynchronously I have to wait with await for the result and so my event must be out of asynchronous. However, as soon as I make my events asynchronous they are no longer executed.

To Reproduce Program an async event in a plugin

Version Actually master

Platform windows

My code

        private async void ClientEnter(object sender, ClientEnterView e)
        {
            ClientDbInfo clientDbInfo = (await tsClient.ClientDbInfo(e.DatabaseId)).Value;
            Console.WriteLine(clientDbInfo.Uid);
        }

Another Try without async (even doesn't work. Event is called, but stops by ClientDbInfo())

        private void ClientEnter(object sender, ClientEnterView e)
        {
            ClientDbInfo clientDbInfo = tsClient.ClientDbInfo(e.DatabaseId).GetAwaiter().GetResult().Value;
            Console.WriteLine(clientDbInfo.Uid);
        }

MoroseCorpse avatar Aug 28 '22 12:08 MoroseCorpse