Removed ThreadPool threads in favour of plain threads.
See NyxStudios/TerrariaAPI-Server@b1d62b6cbd for details.
This commit is contained in:
parent
a7ac433bfa
commit
4eca66a024
4 changed files with 36 additions and 20 deletions
|
|
@ -44,8 +44,15 @@ namespace TShockAPI
|
||||||
public void Backup()
|
public void Backup()
|
||||||
{
|
{
|
||||||
lastbackup = DateTime.UtcNow;
|
lastbackup = DateTime.UtcNow;
|
||||||
ThreadPool.QueueUserWorkItem(DoBackup);
|
Thread t = new Thread(() => {
|
||||||
ThreadPool.QueueUserWorkItem(DeleteOld);
|
DoBackup(null);
|
||||||
|
DeleteOld(null);
|
||||||
|
});
|
||||||
|
t.Name = "Backup Thread";
|
||||||
|
t.Start();
|
||||||
|
|
||||||
|
// ThreadPool.QueueUserWorkItem(DoBackup);
|
||||||
|
// ThreadPool.QueueUserWorkItem(DeleteOld);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DoBackup(object o)
|
private void DoBackup(object o)
|
||||||
|
|
|
||||||
|
|
@ -37,13 +37,21 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
initialized = true;
|
initialized = true;
|
||||||
serverId = Guid.NewGuid().ToString(); // Gets reset every server restart
|
serverId = Guid.NewGuid().ToString(); // Gets reset every server restart
|
||||||
ThreadPool.QueueUserWorkItem(SendUpdate);
|
// ThreadPool.QueueUserWorkItem(SendUpdate);
|
||||||
|
Thread t = new Thread(() => {
|
||||||
|
do {
|
||||||
|
Thread.Sleep(1000 * 60 * 5);
|
||||||
|
SendUpdate(null);
|
||||||
|
} while(true);
|
||||||
|
});
|
||||||
|
t.IsBackground = true;
|
||||||
|
t.Name = "TShock Stat Tracker Thread";
|
||||||
|
t.Start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SendUpdate(object info)
|
private void SendUpdate(object info)
|
||||||
{
|
{
|
||||||
Thread.Sleep(1000 * 60 * 5);
|
|
||||||
JsonData data;
|
JsonData data;
|
||||||
|
|
||||||
if(ServerApi.RunningMono)
|
if(ServerApi.RunningMono)
|
||||||
|
|
@ -105,8 +113,6 @@ namespace TShockAPI
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadPool.QueueUserWorkItem(SendUpdate);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<ProductVersion>8.0.30703</ProductVersion>
|
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
|
||||||
<ProjectGuid>{49606449-072B-4CF5-8088-AA49DA586694}</ProjectGuid>
|
<ProjectGuid>{49606449-072B-4CF5-8088-AA49DA586694}</ProjectGuid>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
|
@ -62,21 +60,18 @@
|
||||||
<Reference Include="Mono.Data.Sqlite">
|
<Reference Include="Mono.Data.Sqlite">
|
||||||
<HintPath>..\prebuilts\Mono.Data.Sqlite.dll</HintPath>
|
<HintPath>..\prebuilts\Mono.Data.Sqlite.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="MySql.Data, Version=6.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
|
||||||
<SpecificVersion>False</SpecificVersion>
|
|
||||||
<HintPath>..\prebuilts\MySql.Data.dll</HintPath>
|
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="BCrypt.Net">
|
<Reference Include="BCrypt.Net">
|
||||||
<HintPath>..\prebuilts\BCrypt.Net.dll</HintPath>
|
<HintPath>..\prebuilts\BCrypt.Net.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
|
||||||
<SpecificVersion>False</SpecificVersion>
|
|
||||||
<HintPath>..\prebuilts\Newtonsoft.Json.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Web" />
|
<Reference Include="System.Web" />
|
||||||
|
<Reference Include="MySql.Data">
|
||||||
|
<HintPath>..\prebuilts\MySql.Data.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Newtonsoft.Json">
|
||||||
|
<HintPath>..\prebuilts\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="BackupManager.cs" />
|
<Compile Include="BackupManager.cs" />
|
||||||
|
|
@ -180,7 +175,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\TerrariaServerAPI\TerrariaServer.csproj">
|
<ProjectReference Include="..\TerrariaServerAPI\TerrariaServer.csproj">
|
||||||
<Project>{6877506e-adc6-4142-98a6-79e4fa02855a}</Project>
|
<Project>{6877506E-ADC6-4142-98A6-79E4FA02855A}</Project>
|
||||||
<Name>TerrariaServer</Name>
|
<Name>TerrariaServer</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,16 @@ namespace TShockAPI
|
||||||
|
|
||||||
public UpdateManager()
|
public UpdateManager()
|
||||||
{
|
{
|
||||||
ThreadPool.QueueUserWorkItem(CheckForUpdates);
|
Thread t = new Thread(() => {
|
||||||
|
do {
|
||||||
|
CheckForUpdates(null);
|
||||||
|
} while (true);
|
||||||
|
});
|
||||||
|
|
||||||
|
t.Name = "TShock Update Thread";
|
||||||
|
t.IsBackground = true;
|
||||||
|
|
||||||
|
t.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckForUpdates(object state)
|
private void CheckForUpdates(object state)
|
||||||
|
|
@ -53,7 +62,6 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.Sleep(CheckXMinutes * 60 * 1000);
|
Thread.Sleep(CheckXMinutes * 60 * 1000);
|
||||||
ThreadPool.QueueUserWorkItem(CheckForUpdates);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateCheck(object o)
|
public void UpdateCheck(object o)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue