Click here to Skip to main content
14,876,850 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Path class in .NET Pin
Andy *M*26-Apr-07 3:17
MemberAndy *M*26-Apr-07 3:17 
QuestionMultithreading-Performance Pin
roddy189124-Apr-07 20:21
Memberroddy189124-Apr-07 20:21 
Hello!

I've got a problem with multithreading.

One should think that every Thread-Model causes overhead and is responsible
for a little bit lost of performance on a singel-Core CPU!
In my Case, the sequentiell version is about 3 % slower than the Threading-versions.
Has anybody an explanation for this?


//the worker-function
public void Function()
{
for (int i = 0; i < 10000; i++)
{
for (int j = 0; j < 10000; j++)
{
j = j + 1;
j = j - 1;
}
}
}

//Needed to set the AutoResetEvent -> Overhead?
public void FunctionNT(Object obj)
{
Function();
Object tmp = obj;
if (tmp != null)
{
((AutoResetEvent)obj).Set();
}
}

// sequentiell Version
class SequentiellTest : ThreadingParent
{
public SequentiellTest(int piterations)
{
this.iterations = piterations;
}

public void Run()
{
Worker wrk = new Worker();

for (int i = 0; i < iterations; i++)
{
wrk.Function();
}
}
}


// Version newThread
class NewThreadTest : ThreadingParent
{

public NewThreadTest(int piterations)
{
this.iterations = piterations;
}

public void Run()
{
AutoResetEvent[] ready = new AutoResetEvent[iterations];// = new AutoResetEvent(false);

Worker wrk = new Worker();

Thread[] tda = new Thread[iterations];

for (int i = 0; i < iterations; i++)
{
ready[i] = new AutoResetEvent(false);
tda[i] = new Thread(wrk.FunctionNT);
tda[i].Start(ready[i]);
}

//wait until all Threads are Ready
for (int j = 0; j < iterations; j++)
{
ready[j].WaitOne();
}
}
}


// Example for a Calling-Function
private void NewThreadStart()
{
//start the Stopwatch
stp.Start();

//Init NewThreadClass
NewThreadTest ntt = new NewThreadTest(Convert.ToInt16(tbIterations.Text));
ntt.Run();

//Stop the Stopwatch
stp.Stop();
}

Questionwhat is satellite assembly..? Pin
Balagurunathan S24-Apr-07 19:41
MemberBalagurunathan S24-Apr-07 19:41 
AnswerRe: what is satellite assembly..? Pin
MatrixCoder24-Apr-07 19:49
MemberMatrixCoder24-Apr-07 19:49 
GeneralRe: what is satellite assembly..? Pin
Balagurunathan S24-Apr-07 22:04
MemberBalagurunathan S24-Apr-07 22:04 
GeneralRe: what is satellite assembly..? Pin
szukuro24-Apr-07 23:15
Memberszukuro24-Apr-07 23:15 
AnswerRe: what is satellite assembly..? Pin
Jaiprakash M Bankolli24-Apr-07 23:15
MemberJaiprakash M Bankolli24-Apr-07 23:15 
Questionsealed UI classes Pin
DotNetInterest24-Apr-07 7:08
MemberDotNetInterest24-Apr-07 7:08 
AnswerRe: sealed UI classes Pin
Pete O'Hanlon24-Apr-07 9:54
mvePete O'Hanlon24-Apr-07 9:54 
AnswerRe: sealed UI classes [modified] Pin
Jaiprakash M Bankolli25-Apr-07 23:05
MemberJaiprakash M Bankolli25-Apr-07 23:05 
Question[Interop] Connectionpoint Advise hangs Pin
User 21559724-Apr-07 6:57
MemberUser 21559724-Apr-07 6:57 
QuestionWhy no GC.Kill(object)? Pin
Tristan Rhodes24-Apr-07 5:36
MemberTristan Rhodes24-Apr-07 5:36 
AnswerRe: Why no GC.Kill(object)? Pin
Colin Angus Mackay24-Apr-07 5:40
MemberColin Angus Mackay24-Apr-07 5:40 
GeneralRe: Why no GC.Kill(object)? Pin
Tristan Rhodes24-Apr-07 5:57
MemberTristan Rhodes24-Apr-07 5:57 
GeneralRe: Why no GC.Kill(object)? Pin
Dave Kreskowiak24-Apr-07 6:21
mveDave Kreskowiak24-Apr-07 6:21 
GeneralRe: Why no GC.Kill(object)? Pin
Tristan Rhodes24-Apr-07 7:07
MemberTristan Rhodes24-Apr-07 7:07 
AnswerRe: Why no GC.Kill(object)? Pin
Daniel Turini24-Apr-07 6:44
MemberDaniel Turini24-Apr-07 6:44 
Question.NET on linux/unix Pin
Waskira23-Apr-07 22:30
MemberWaskira23-Apr-07 22:30 
AnswerRe: .NET on linux/unix Pin
Tristan Rhodes24-Apr-07 3:51
MemberTristan Rhodes24-Apr-07 3:51 
GeneralRe: .NET on linux/unix Pin
Ray Cassick24-Apr-07 13:23
MemberRay Cassick24-Apr-07 13:23 
AnswerRe: .NET on linux/unix Pin
Scott Dorman24-Apr-07 3:51
professionalScott Dorman24-Apr-07 3:51 
GeneralRe: .NET on linux/unix Pin
Brady Kelly24-Apr-07 18:57
MemberBrady Kelly24-Apr-07 18:57 
Question"Stub" application Pin
Miszou23-Apr-07 9:22
MemberMiszou23-Apr-07 9:22 
AnswerRe: "Stub" application Pin
kubben23-Apr-07 9:49
Memberkubben23-Apr-07 9:49 
AnswerRe: "Stub" application Pin
Dave Kreskowiak23-Apr-07 9:53
mveDave Kreskowiak23-Apr-07 9:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.