Thread

DC4_SERSH

New Member
Member
Dec 6, 2017
18
1
1
28
Russia
Why does not output to the console work in a new thread?
Can anyone encountered - not how to not send a message to the server console from a new thread
 

DC4_SERSH

New Member
Member
Dec 6, 2017
18
1
1
28
Russia
be more obvious please
C#:
public class Init
    {
        public static void Initialize()
        {
            new Thread(new Class1().Test).Start(); // server-side
        }
    }
Code:
public class Class1
    {
        public void Test()
        {
            System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Highest;
            UnityEngine.Debug.Log("Initialize");
        }
    }
But the message never gets me
 

ice cold

Active Member
Trusted Member
Member
Oct 24, 2016
606
876
43
Canada
C#:
public class Init
    {
        public static void Initialize()
        {
            new Thread(new Class1().Test).Start(); // server-side
        }
    }
Code:
public class Class1
    {
        public void Test()
        {
            System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Highest;
            UnityEngine.Debug.Log("Initialize");
        }
    }
But the message never gets me
to log try Logger.Log("Initialize");
 

DC4_SERSH

New Member
Member
Dec 6, 2017
18
1
1
28
Russia
It does not work! From the new thread it does not send out as for some reason
He also uses Debug.Log.


  1. Code:
    public static void Log(string Message, UnityEngine.Object Context = null)
            {
                Debug.Log(Message, Context);
                Message = "[Console] " + Message;
                WriteLog(Message);
            }
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
I’m pretty sure you can’t print messages to console using threading, But you can still print them to the server
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
What code are you using?
Also do you have Debug enabled in Fougerite.cfg?
 

salva

Friendly self-taught developer
Administrator
Jan 31, 2016
577
612
63
Why does not output to the console work in a new thread?
Can anyone encountered - not how to not send a message to the server console from a new thread
If I'm not wrong you should use ConsoleSystem.Print("some message");
Or
ConsoleSystem.LogError("some message");
To show messages called from a job in the background can be displayed

Some example here: https://github.com/salvadj1/AutoSave/blob/master/AutoSave_v101.cs#L124

Also In the same way if you need to send commands to the console .... ConsoleSystem.Run("save.all");

Example here: https://github.com/salvadj1/AutoSave/blob/master/AutoSave_v101.cs#L127
Try use it and tell me if work :D
Regards!!
 

DC4_SERSH

New Member
Member
Dec 6, 2017
18
1
1
28
Russia
If I'm not wrong you should use ConsoleSystem.Print("some message");
Or
ConsoleSystem.LogError("some message");
To show messages called from a job in the background can be displayed

Some example here: https://github.com/salvadj1/AutoSave/blob/master/AutoSave_v101.cs#L124

Also In the same way if you need to send commands to the console .... ConsoleSystem.Run("save.all");

Example here: https://github.com/salvadj1/AutoSave/blob/master/AutoSave_v101.cs#L127
Try use it and tell me if work :D
Regards!!
I found a better way for myself
C#:
[DllImport("dc4_lib.dll")]
public static extern string Debug_log(string text);

NetworkManager.Debug_log(((IPEndPoint)Client.Client.RemoteEndPoint).Address + " disconnected");
 
Last edited: