B
bilosta
Hello to everybody
I'm new in win apllications and C#. I have a problem with Threading.
Here is my problem:
I have a form with button named: BupisiStudente, when I click on it a
call next method:
private void BUpisiStudente_Click(object sender, EventArgs e)
{
......
//calling method from object "mojaObrada"
if
(mojaObrada.UpisiStudentaZaIspit(IDIspita,idStudenta,ImeProfesoraUFormi,PasswordProfesora))
.....
In Obrada class (object mojaObrada) "UpisiStudentaZaIspit" method:
public bool UpisiStudentaZaIspit(int ID_Ispit, int ID_Student, string
username, string pass)
{
...
//creating thread and starting it
Thread workerThread = new Thread(new
ThreadStart(ShowSacekajte));
workerThread.Start();
//calling service
if (mojServis.UpisiStudentaZaIspit(ID_Ispit, ID_Student,
Encrypt(sifra + IDIspitaString), username, pass))
{
//closing form "Molim"
Molim.Close();
//aborting thread
workerThread.Abort();
return true;
}
else
{
//closing form "Molim"
Molim.Close();
//aborting thread
workerThread.Abort();
return true;
}
//Method ShowSacekajte
public void ShowSacekajte()
{
Molim.ShowDialog();
}
Everithing works fine, but in 1000 click or 500 nevermind, i get
exception for thread. Can enyone help mi how to "get over" this
problem.
Thanx in advance.
PS. I'm working in VS2005
I'm new in win apllications and C#. I have a problem with Threading.
Here is my problem:
I have a form with button named: BupisiStudente, when I click on it a
call next method:
private void BUpisiStudente_Click(object sender, EventArgs e)
{
......
//calling method from object "mojaObrada"
if
(mojaObrada.UpisiStudentaZaIspit(IDIspita,idStudenta,ImeProfesoraUFormi,PasswordProfesora))
.....
In Obrada class (object mojaObrada) "UpisiStudentaZaIspit" method:
public bool UpisiStudentaZaIspit(int ID_Ispit, int ID_Student, string
username, string pass)
{
...
//creating thread and starting it
Thread workerThread = new Thread(new
ThreadStart(ShowSacekajte));
workerThread.Start();
//calling service
if (mojServis.UpisiStudentaZaIspit(ID_Ispit, ID_Student,
Encrypt(sifra + IDIspitaString), username, pass))
{
//closing form "Molim"
Molim.Close();
//aborting thread
workerThread.Abort();
return true;
}
else
{
//closing form "Molim"
Molim.Close();
//aborting thread
workerThread.Abort();
return true;
}
//Method ShowSacekajte
public void ShowSacekajte()
{
Molim.ShowDialog();
}
Everithing works fine, but in 1000 click or 500 nevermind, i get
exception for thread. Can enyone help mi how to "get over" this
problem.
Thanx in advance.
PS. I'm working in VS2005