mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
+ Rework task scheduling in chatbots + Switch back terrain processing to tasks
This commit is contained in:
parent
c1cfaf520d
commit
95d6318350
7 changed files with 517 additions and 461 deletions
|
|
@ -24,7 +24,6 @@ namespace MinecraftClient.ChatBots
|
|||
private string owner;
|
||||
private bool csharp;
|
||||
private Thread thread;
|
||||
private ManualResetEvent tpause;
|
||||
private Dictionary<string, object> localVars;
|
||||
|
||||
public Script(string filename)
|
||||
|
|
@ -157,12 +156,11 @@ namespace MinecraftClient.ChatBots
|
|||
//Initialize thread on first update
|
||||
if (thread == null)
|
||||
{
|
||||
tpause = new ManualResetEvent(false);
|
||||
thread = new Thread(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
CSharpRunner.Run(this, tpause, lines, args, localVars);
|
||||
CSharpRunner.Run(this, lines, args, localVars);
|
||||
}
|
||||
catch (CSharpException e)
|
||||
{
|
||||
|
|
@ -173,16 +171,14 @@ namespace MinecraftClient.ChatBots
|
|||
LogToConsole(e.InnerException);
|
||||
}
|
||||
});
|
||||
thread.Name = "MCC Script - " + file;
|
||||
thread.Start();
|
||||
}
|
||||
|
||||
//Let the thread run for a short span of time
|
||||
if (thread != null)
|
||||
//Unload bot once the thread has finished running
|
||||
if (thread != null && !thread.IsAlive)
|
||||
{
|
||||
tpause.Set();
|
||||
tpause.Reset();
|
||||
if (!thread.IsAlive)
|
||||
UnloadBot();
|
||||
UnloadBot();
|
||||
}
|
||||
}
|
||||
else //Classic MCC script interpreter
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue