Click to See Complete Forum and Search --> : Multi Threading


bflosabre91
February 26th, 2008, 11:51 AM
i declare a thread which runs a Sub that just opens up a loading screen while
a query is run on the OS thread. i want to close the loading thread when the
query is done but without using thread.abort(). anyone let me know if there is
a way to do this. If not, i would be ok with using thread.abort() as i dont care
about losing anything from the loading thread because all it does is display a
form on the screen. but i keep getting the ThreadAbortException "Thread was
being aborted" error. so if anyone can help me to hide this error i would really
appreciate it. thanks

satanorz
February 26th, 2008, 06:01 PM
Hi!, here's some useful information about threads, its in C#, but is easy to understand the basics.

http://www.yoda.arachsys.com/csharp/threads/

As i can remember, when a thread has nothing to do, it ends, so with your call to Abort you're forzing to exit and give an exception to show you why it has been closed.

Hope this information is useful to you :wave:

bflosabre91
February 27th, 2008, 07:56 AM
thanks for the reply. However the problem is have is that the thread will never stop itself because it is dependent on the OS thread. So i need to abort() the declared thread depending on OS thread. but the ThreadAbortException gets thrown whenever you use Abort(), even if you have a Try Catch on it. I just need to figure out how to not show the error, cause i cant get that to work.
thanks alot, i appreciate any help

Marraco
February 27th, 2008, 10:28 AM
Hi!, here's some useful information about threads, its in C#, but is easy to understand the basics.

http://www.yoda.arachsys.com/csharp/threads/
...
Interesting Link. I want to start learning about multithreading, so, I want to translate the code to VB.net.

This c# code I had get from that link:
using System;
using System.Threading;

public class Test
{
static void Main()
{
Counter foo = new Counter();
ThreadStart job = new ThreadStart(foo.Count);
Thread thread = new Thread(job);
thread.Start();

for (int i=0; i < 5; i++)
{
Console.WriteLine ("Main thread: {0}", i);
Thread.Sleep(1000);
}
}
}

public class Counter
{
public void Count()
{
for (int i=0; i < 10; i++)
{
Console.WriteLine ("Other thread: {0}", i);
Thread.Sleep(500);
}
}
}have the "using" statement. żIs correct to translate it to VB.NET as the "Implements" statement?

satanorz
February 27th, 2008, 12:28 PM
Hi!, i think that the correct translation to VB.NET will be


Imports System;
Imports System.Threading;

HanneSThEGreaT
February 28th, 2008, 03:04 AM
There's also a free online C# to VB.NET converter :
http://labs.developerfusion.co.uk/convert/csharp-to-vb.aspx