Author Topic: Visual C# help  (Read 1133 times)

ViciouZ

  • Map Committee
  • Autococker
  • Posts: 2227
Visual C# help
« on: December 29, 2007, 02:54:56 PM »
Well I have a next to no experience of C#.

Currently when I start a process, the application freezes until the process has finished and exited. Is there any way I can stop this happening without using threads? The structure of my code stops threads being feasible.

Eiii

  • Autococker
  • Posts: 4595
Re: Visual C# help
« Reply #1 on: December 29, 2007, 03:47:28 PM »
No. You need to use threads for there to be more than one thread. :P
There are some objects that make threading a bit easier. But most likely, you're gonna have to hack your code until it can handle threads.

Loser

  • PGP
  • Posts: 4
Re: Visual C# help
« Reply #2 on: January 01, 2008, 03:14:39 AM »
Aww you gotta stop using such an extensive loop, you have no choice but mutlithreading, its not that hard, around 2 lines of code will do(note i learn vb.net not c#)

Deranged

  • 68 Carbine
  • Posts: 409
Re: Visual C# help
« Reply #3 on: January 01, 2008, 11:14:46 AM »
.Net provides you with a very easy to use Thread class for multithreading. look it up on msdn.

Cobo

  • Autococker
  • Posts: 1362
Re: Visual C# help
« Reply #4 on: January 01, 2008, 02:01:26 PM »
All you have to do is:
Code: [Select]
private Thread th;

public constructor()
{
   CheckForIllegalCrossThreadCalls = false;
   th = new Thread(new ThreadStart(MyNewThread));
   th.Start();
}

private void MyNewThread()
{
    // Add new thread code here.
}

Note the 'constructor' function is the actual constructor of the form, not a function named constructor.