Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Threading issues after calling SA-MP natives #220

Closed
SnowDog4822 opened this issue Sep 30, 2017 · 2 comments
Closed

Threading issues after calling SA-MP natives #220

SnowDog4822 opened this issue Sep 30, 2017 · 2 comments

Comments

@SnowDog4822
Copy link

When attempting to use await in the current 0.8.0-alpha1 release on .NET Core 2.0 the method will not proceed past the await or complete. I tested this on both my own game mode and @ikkentim's TestMode. In both cases, any method using await will not complete.

When testing the TestMode in particular, this issue arose both with the /dialogtest command as well as a simple command that I wrote for testing purposes.

This command:

        [Command("testawait")]
        public static async void testAwait(BasePlayer player)
        {
            Console.WriteLine("Waiting 2 seconds...");

            await Task.Delay(2000);

            Console.WriteLine("Success!");
        }

resulted in only the Waiting 2 seconds... line being printed. The success message never printed.

I am unsure if this only affects .NET Core or .NET Core 2.0 in particular.

@ikkentim
Copy link
Owner

ikkentim commented Oct 1, 2017

It works for me 🤔

Waiting 2 seconds...
Success!

Used your code on a fresh, .NET Core 2.0 project

@SnowDog4822
Copy link
Author

I know I've already contacted you about this in Slack, but for the record I'll update this issue. This is apparently some sort of threading problem somewhere in the SampSharp.Core.Threading either with the MessageQueue or MessagePump and it can be reproduced by calling a native (such as SetGameModeText()) anywhere in the gamemode and then attempting to use async/await afterwards. Once the native has been called, it has a random chance (it doesn't reproduce 100% of the time) of hanging up all future asynchronous methods in the SampSharp server.

@SnowDog4822 SnowDog4822 changed the title await not working properly in 0.8.0-alpha1 on .NET Core 2.0 Threading issues after calling SA-MP natives Oct 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants