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

AltV.Net.Exceptions.IllegalThreadException by using AsyncContext #554

Closed
Doxoh opened this issue May 11, 2022 · 0 comments · Fixed by #564
Closed

AltV.Net.Exceptions.IllegalThreadException by using AsyncContext #554

Doxoh opened this issue May 11, 2022 · 0 comments · Fixed by #564

Comments

@Doxoh
Copy link
Contributor

Doxoh commented May 11, 2022

I have created a small code reproduction for this bug: reproduction

If a method is called on ToAsync() the CheckIfEntityExists is called in wrong thread -> In the project their are by debug use debug-dlls from altv c# module

    [AsyncEntity(typeof(IGamePlayer))]
    public partial class GamePlayer : Player, IGamePlayer
    {
      public void SetModel(uint model) {
        this.Model = model;
      }
    }

    public void SetModel(IGamePlayer player) {
      player.ToAsync().SetModel(PedModel.FreemodeFemale01);
    }

If you test the reproduction follow the steps:

Get IllegalThreadException:

  1. Start Server
  2. Connect to 127.0.0.1:7788
  3. Press "T" to open chat
  4. Type "/male2" -> Command is here -> https://github.com/Doxoh/altv-csharp-module-async-bug/blob/master/Test-csharp/ChatController.cs#L73
  5. Check Console -> Exception

Get no IllegalThreadException:

  1. Start Server
  2. Connect to 127.0.0.1:7788
  3. Press "T" to open chat
  4. Type "/male1" -> Command is here -> https://github.com/Doxoh/altv-csharp-module-async-bug/blob/master/Test-csharp/ChatController.cs#L64
  5. Check Console -> Everything works

Next strange behavior:

  1. Start Server
  2. Connect to 127.0.0.1:7788
  3. Press "T" to open chat
  4. Type "/male1" -> Command is here -> https://github.com/Doxoh/altv-csharp-module-async-bug/blob/master/Test-csharp/ChatController.cs#L64
  5. Check Console -> Everything works
  6. Press "T" to open chat
  7. Type "/male2" -> Command is here -> https://github.com/Doxoh/altv-csharp-module-async-bug/blob/master/Test-csharp/ChatController.cs#L64
  8. Check Console -> Everything works
  9. Wait 2 minutes
  10. Type "/male2" -> Command is here -> https://github.com/Doxoh/altv-csharp-module-async-bug/blob/master/Test-csharp/ChatController.cs#L64
  11. Check Console -> Exception
zziger added a commit to zziger/coreclr-module that referenced this issue May 15, 2022
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

Successfully merging a pull request may close this issue.

1 participant