Quote:
Originally Posted by denominator
Might seem a little off topic but at the same time it isn`t lol. In C# in the error list is the most important error the first error shown? I`m rewatching video tutorials of C# again and will continue until I can get my head around it but can`t exactly ask the author of the videos. There seems so far to be far to many uses of the word method >.<
Console.Writeline with writeline being the method. But then he says Static void Main(string[] args) is also a method >.< To much method lmfao.
|
In that case Main is a method/function.
As argon said... basically everything in programming is going to be a method.
NOTE: this is not really true as you have classes, structs, etcetcetc. These objects are very important.
So what's a method? A method is something that... 'does something'. A method is a section of code which you call when you want a specific thing to happen. This could be anything from, writing something to the console (WriteLine("text");) to your own more complex functions.... say a NextPointInPath(CurrentLocation, TargetLocation);.
As for the questions on threads... That is something that's both simple to explain yet not exactly a simple topic.
By default a program has it's one main thread... This is the thread that runs the Main() argument. A thread can be thought of a little bit like a processor. It can do one thing at a time and one thing only... If you tell a thread to wait... it can't perform any other action until it's done waiting (thread.sleep(X);).
When you create a new thread you allow certain actions to be calculated by the server at the same time.
For example in this proxy I create 2 threads per client as they connect.
Thread 1: Packet thread runs through the packet queue and sends the packets to the server or client. This thread loops incredibly fast to ensure that all packets are being sent in a timely manner
Thread 2: Botting thread runs through your botting code to control any AI/Actions you want the bot to do for your character. The thread loops fairly quickly so that even fast actions can continue to occur (IE: Fast fatal strike)
By spawning these new threads you can avoid worrying about stopping a thread which will then say... stop packets from being sent to the correct place.
There's way, way, way more to threads but that's essentially it... a thread is a single line of processing. More threads = more single lines of processing. Keep in mind your computer can technically only run 1 thread per cpu core at a time... not that you'll really notice that as cpu's cycle incredibly quickly.