Vote count: 0
My program is using Async Callbacks, so right after 'beginconnect' is executed, my program closes. Besides doing an infinite while loop or Thread.Sleep (both of which eat up 30% of my CPU), is there any way to pause the main thread so the async threads can do send & receive data? if I place a messagebox.show(); at the end of the main function, that does the trick, but then the user has a random messagebox just sitting there.
static void Main()
{
if (Process.GetProcessesByName(p.ProcessName).Length == 1) //prevent duplicate process
{
Console.WriteLine("Initializing");
Console.ForegroundColor = ConsoleColor.Cyan;
client.BeginConnect("127.0.0.1", 7777, onConnect, null); //IAsync, I have it set as loopback for debugging purposes
}
//I could put a messagebox here which would causes the main thread to not close, but it's awkward
}
asked 36 secs ago
Halt Main Thread
Aucun commentaire:
Enregistrer un commentaire