Skip to content

Instantly share code, notes, and snippets.

@squaregear
Created June 20, 2017 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save squaregear/80821130d221727c3836dba3224bf93e to your computer and use it in GitHub Desktop.
Save squaregear/80821130d221727c3836dba3224bf93e to your computer and use it in GitHub Desktop.
Demonstrates crash from AsterNet thread
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using AsterNET.Manager;
using AsterNET.Util;
namespace AsterNetTest
{
class Program
{
static void Main(string[] args)
{
Dialer d = new Dialer();
Thread.Sleep(30 * 60 * 1000);
}
}
class Dialer : ThreadClass
{
public ManagerConnection Manager { get; set; }
public Dialer()
{
Console.WriteLine($"{DateTime.Now} Connecting");
Manager = new ManagerConnection("myhost", 5038, "myuser", "mypassword");
Manager.PingInterval = 0;
Manager.Login();
IsBackground = true;
Start();
}
public override void Run()
{
while (true)
{
if (!Manager.IsConnected())
{
Console.WriteLine($"{DateTime.Now} Reconnecting");
Manager.Logoff();
Manager = new ManagerConnection("myhost", 5038, "myuser", "mypassword");
Manager.PingInterval = 0;
Manager.Login();
}
Thread.Sleep(15 * 1000);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment