Solved C# Plugin - Random Crash with threading

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
Yes a little more:

[5/15/2016 3:31:08 PM] [Error] Error for Taryn System.NullReferenceException: Object reference not set to an instance of an object
at Fougerite.Loom.QueueOnMainThread (System.Action action, Single time) [0x00000] in <filename unknown>:0
at Fougerite.Loom.QueueOnMainThread (System.Action action) [0x00000] in <filename unknown>:0
at Fougerite.Player.Disconnect () [0x00000] in <filename unknown>:0
[5/15/2016 3:31:08 PM] [Error] Error for Taryn (my Steam ID - removed it)
[5/15/2016 3:31:08 PM] [Error] Error for Taryn 2
[5/15/2016 3:31:08 PM] [Error] Error for Taryn 1
Logger.LogError("Error for Taryn " + ex );
Logger.LogError("Error for Taryn " + uid);
Logger.LogError("Error for Taryn " + Thread.CurrentThread.ManagedThreadId);
Logger.LogError("Error for Taryn " + Util.GetUtil().MainThreadID);

What the fuck.
 

tarynkelley

Retired Staff
Retired Staff
Trusted Member
Nov 14, 2015
575
178
28
Parts Unknown
I even get the message when I write my own Loom Kick Function and execute it from the thread.

C#:
public void Kick(Player pl)
        {
            try
            {

                if (Util.GetUtil().CurrentWorkingThreadID != Util.GetUtil().MainThreadID)
                {
                    Loom.QueueOnMainThread(() =>
                    {
                        Kick(pl);
                    });
                    return;
                }

                pl.Disconnect(true);

            }

            catch (Exception ex1)
            {

                Logger.Log(ex1.ToString());
            }

        }
 

tarynkelley

Retired Staff
Retired Staff
Trusted Member
Nov 14, 2015
575
178
28
Parts Unknown
Loom works without problems outside of the thread.

E.g.

else if ((cmd == "kicktest") && Player.Admin)
{


Kick(Player);


}

Works fine.