Skip to content

Commit

Permalink
Trying to cut execution time with Parallelism, has adverse effect on …
Browse files Browse the repository at this point in the history
…performance
  • Loading branch information
Kritul Rathod committed Mar 22, 2020
1 parent 6a121bc commit 15fe657
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ private void button1_Click(object sender, EventArgs e)
Debug.WriteLine($@"TotalSeconds: {watch.Elapsed.TotalSeconds}");
}

private void button2_Click(object sender, EventArgs e)
{
var watch = new System.Diagnostics.Stopwatch();

watch.Start();

Parallel.For(0, 100000, i =>
{
ExportForm(i);
});

watch.Stop();
Debug.WriteLine($@"TotalSeconds: {watch.Elapsed.TotalSeconds}");
}

private void ExportForm(int id)
{
using (Form form = new Form())
Expand All @@ -49,7 +64,7 @@ private void ExportForm(int id)
}

//Export using the Third Party Export Component

ForceGarbageCollect();
TextBoxContent = string.Empty;
}
Expand Down

0 comments on commit 15fe657

Please sign in to comment.