| View previous topic :: View next topic |
| Author |
Message |
Sneak Grandmaster Cheater Supreme
Reputation: 0
Joined: 05 Nov 2008 Posts: 1895
|
Posted: Thu Dec 10, 2009 3:28 pm Post subject: [C#] Threads |
|
|
Can somebody give me a rundown and example of threads in C#?
_________________
|
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Thu Dec 10, 2009 4:21 pm Post subject: |
|
|
| Don't try to run before you can walk (or I guess in this case, walk before you can crawl). I'm relatively certain you just learned how to call a class method a week or two ago.
|
|
| Back to top |
|
 |
Sneak Grandmaster Cheater Supreme
Reputation: 0
Joined: 05 Nov 2008 Posts: 1895
|
Posted: Thu Dec 10, 2009 9:05 pm Post subject: |
|
|
yeah I think so too xD. I just Dled a source with Multi Threading, and it looks complicated :X
_________________
|
|
| Back to top |
|
 |
marryjohnson How do I cheat?
Reputation: 0
Joined: 11 Dec 2009 Posts: 7
|
Posted: Sat Dec 12, 2009 6:59 am Post subject: |
|
|
Example of Thread
ThreadSample.cs
using System;
using System.Threading;
namespace Suite101.CSharp
{
public class ExampleThreads
{
public static void Main()
{
ExampleThreads sample = new ExampleThreads();
sample.CreateThreads();
}
public void CreateThreads()
{
Thread firstThread = new Thread( new ThreadStart( FirstEntryPoint ) );
Thread secondThread = new Thread( new ThreadStart( SecondEntryPoint ) );
firstThread.Start();
secontThread.Start();
}
public void FirstEntryPoint()
{
// Do Nothing
}
public void SecondEntryPoint()
{
// Do Nothing
}
}
}
_________________
memory cards |
|
| Back to top |
|
 |
Sneak Grandmaster Cheater Supreme
Reputation: 0
Joined: 05 Nov 2008 Posts: 1895
|
Posted: Sun Dec 13, 2009 11:31 am Post subject: |
|
|
ooh thank you.
_________________
|
|
| Back to top |
|
 |
iPromise Grandmaster Cheater
Reputation: -1
Joined: 27 Jun 2009 Posts: 529 Location: Canada
|
Posted: Sun Dec 13, 2009 12:14 pm Post subject: |
|
|
Example:
| Code: |
#include <windows.h>
#include <iostream>
using namespace std;
bool InputMessage()
{
while (1)
{
MessageBoxA(0, "iPromise", "iPromise", MB_OK);
Sleep(10);
}
return true;
}
void main()
{
CreateThread(0, 0, (LPTHREAD_START_ROUTINE) InputMessage(), 0, 0, 0);
cin.get();
}
|
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sun Dec 13, 2009 1:22 pm Post subject: |
|
|
| iPromise wrote: | Example:
| Code: |
#include <windows.h>
#include <iostream>
using namespace std;
bool InputMessage()
{
while (1)
{
MessageBoxA(0, "iPromise", "iPromise", MB_OK);
Sleep(10);
}
return true;
}
void main()
{
CreateThread(0, 0, (LPTHREAD_START_ROUTINE) InputMessage(), 0, 0, 0);
cin.get();
}
|
|
That is a horrible example of multithreading/concurrency
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Sun Dec 13, 2009 6:25 pm Post subject: |
|
|
he asks for help in C# and you go ahead and post the worst example possible in another language.
|
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Sun Dec 13, 2009 6:59 pm Post subject: |
|
|
| slovach wrote: |
he asks for help in C# and you go ahead and post the worst example possible in another language.  |
The best part is, is that it isn't even multi-threaded. Instead of passing a function pointer, he calls the function.
|
|
| Back to top |
|
 |
|