Notifications
Clear all

Async Threads [C#]

Page 3 / 4

Absolute Zero
Posts: 119
Topic starter
(@Absolute Zero)
Estimable RivalGamer
Joined: 9 years ago

Awesome tutorial man i'm sure this well get in handy for me someday

Thanks man, hope it does! Its been extremely useful for me in the past couple projects i've worked on.

Reply
xHARDHeMPuS
Posts: 122
(@xhardhempus)
Estimable RivalGamer
Joined: 8 years ago

Great job on your post Absolute Zero

Reply
Cain532
Posts: 1280
(@cain532)
Noble RivalGamer
Joined: 9 years ago

No problem dude! I figured you of all people would like this, since I remember you asking me about threading and bg workers a while back 😀

Definitely :p I found another way, very similar to this, it involves building a thread like that but it gets called in the Program.cs, calling the Thread like ConstantWrite.Start(); above the Application.Run(new Form1) and ConstantWrite.Abort() below that,
The whole thing looks like this;

	public static Thread ConstantWrite = new Thread(new ThreadStart(CWrite));
	public static bool toggle;
	public static void CWrite()
	{
	bool sleep = false;
	while (true)
	{
	//run code inside here, you can use bools to toggle, or ints.
	if (toggle)
	{
	//do stuff;
	}
	if (!sleep)
	     Thread.Sleep(100);
	}
	}
	

Your method looks nice and compact, very similar tho 😀

Also, not sure if this helps, but if you declare your thread outside a button like it is above, you can then call it inside a button just by typing (in my case) ConstantWrite.Start(); 😛

Reply
KranK
Posts: 336
(@KranK)
Reputable RivalGamer
Joined: 9 years ago

Definitely :p I found another way, very similar to this, it involves building a thread like that but it gets called in the Program.cs, calling the Thread like ConstantWrite.Start(); above the Application.Run(new Form1) and ConstantWrite.Abort() below that,
The whole thing looks like this;

	public static Thread ConstantWrite = new Thread(new ThreadStart(CWrite));
	public static bool toggle;
	public static void CWrite()
	{
	bool sleep = false;
	while (true)
	{
	//run code inside here, you can use bools to toggle, or ints.
	if (toggle)
	{
	//do stuff;
	}
	if (!sleep)
	     Thread.Sleep(100);
	}
	}
	

Your method looks nice and compact, very similar tho 😀

Also, not sure if this helps, but if you declare your thread outside a button like it is above, you can then call it inside a button just by typing (in my case) ConstantWrite.Start(); :p

Or you just could hook into any game adress and run your code inside it xD

Reply
Absolute Zero
Posts: 119
Topic starter
(@Absolute Zero)
Estimable RivalGamer
Joined: 9 years ago

Definitely :p I found another way, very similar to this, it involves building a thread like that but it gets called in the Program.cs, calling the Thread like ConstantWrite.Start(); above the Application.Run(new Form1) and ConstantWrite.Abort() below that,
The whole thing looks like this;

	public static Thread ConstantWrite = new Thread(new ThreadStart(CWrite));
	public static bool toggle;
	public static void CWrite()
	{
	bool sleep = false;
	while (true)
	{
	//run code inside here, you can use bools to toggle, or ints.
	if (toggle)
	{
	//do stuff;
	}
	if (!sleep)
	     Thread.Sleep(100);
	}
	}
	

Your method looks nice and compact, very similar tho 😀

Also, not sure if this helps, but if you declare your thread outside a button like it is above, you can then call it inside a button just by typing (in my case) ConstantWrite.Start(); :p

Its the same thing but runs before the first form is loaded, its basically a manual bgw with a toggle because of the bool 😛

Reply
Page 3 / 4