Click here to Skip to main content
15,896,153 members
Home / Discussions / C#
   

C#

 
QuestionThreading concept.. Pin
Ron.S18-Jul-07 22:40
Ron.S18-Jul-07 22:40 
AnswerRe: Threading concept.. Pin
Eduard Keilholz18-Jul-07 22:47
Eduard Keilholz18-Jul-07 22:47 
GeneralRe: Threading concept.. Pin
Ron.S18-Jul-07 22:58
Ron.S18-Jul-07 22:58 
AnswerRe: Threading concept.. Pin
Eduard Keilholz19-Jul-07 0:57
Eduard Keilholz19-Jul-07 0:57 
GeneralRe: Threading concept.. Pin
Ron.S19-Jul-07 2:41
Ron.S19-Jul-07 2:41 
GeneralRe: Threading concept.. Pin
Eduard Keilholz19-Jul-07 3:16
Eduard Keilholz19-Jul-07 3:16 
GeneralRe: Threading concept.. Pin
Ron.S19-Jul-07 19:39
Ron.S19-Jul-07 19:39 
GeneralRe: Threading concept.. Pin
Ron.S19-Jul-07 20:30
Ron.S19-Jul-07 20:30 
this is the code which i am using.

public void loaddata()
{
try
{
conn = new SqlConnection("Data Source=local; Initial Catalog=Northwind; User ID=sa; Password=; Persist Security Info =True;");
adpt = new SqlDataAdapter("Select * from Categories", conn);
ds = new DataSet();
adpt.Fill(ds);
listBox1.DataSource = ds.Tables[0];
//trd
listBox1.DisplayMember = "CategoryName";
Thread.Sleep(1000);
//trd.Start();
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message.ToString());
}
}

on click of the button i am calling that thread.

private void btnStart_Click(object sender, EventArgs e)
{
try
{
// this is wokring

ThreadStart myThreadDelegate = new ThreadStart(loaddata);
trd = new Thread(myThreadDelegate);
trd.Start();
trd.IsBackground = true;
// till here
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}

}

this below code is to stop the thread.
private void btnStop_Click(object sender, EventArgs e)
{
//Thread trd = new Thread(new ThreadStart(this.loaddata));
//trd.Abort();
try
{
if ((trd.ThreadState == ThreadState.Running )|| (trd.ThreadState==ThreadState.Background))
{
trd.Abort();
}

}
catch (ThreadStateException Ex)
{
MessageBox.Show(Ex.ToString(), "Exception",
MessageBoxButtons.OK, MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1);
}
}

please help me..

Bharath.S Ron

QuestionCustom Tab Control Pin
T.EDY18-Jul-07 22:39
T.EDY18-Jul-07 22:39 
QuestionVisual studio error on load Pin
Russell Jones18-Jul-07 22:29
Russell Jones18-Jul-07 22:29 
AnswerRe: Visual studio error on load Pin
originSH18-Jul-07 22:50
originSH18-Jul-07 22:50 
GeneralRe: Visual studio error on load Pin
Russell Jones18-Jul-07 22:57
Russell Jones18-Jul-07 22:57 
GeneralRe: Visual studio error on load Pin
originSH18-Jul-07 23:56
originSH18-Jul-07 23:56 
Questionhandle Printer Pin
Chatura Dilan18-Jul-07 22:17
Chatura Dilan18-Jul-07 22:17 
QuestionChanging color while drag mouse Pin
satsumatable18-Jul-07 22:11
satsumatable18-Jul-07 22:11 
AnswerRe: Changing color while drag mouse Pin
Martin#18-Jul-07 22:51
Martin#18-Jul-07 22:51 
QuestionCharacter not recognised when reading file Pin
Sean_B18-Jul-07 22:10
Sean_B18-Jul-07 22:10 
AnswerRe: Character not recognised when reading file Pin
Guffa18-Jul-07 23:52
Guffa18-Jul-07 23:52 
QuestionXml Serialization Pin
jpeg18-Jul-07 21:58
jpeg18-Jul-07 21:58 
AnswerRe: Xml Serialization Pin
Eduard Keilholz18-Jul-07 22:50
Eduard Keilholz18-Jul-07 22:50 
GeneralRe: Xml Serialization Pin
jpeg18-Jul-07 23:43
jpeg18-Jul-07 23:43 
GeneralRe: Xml Serialization Pin
Martin#18-Jul-07 23:49
Martin#18-Jul-07 23:49 
AnswerRe: Xml Serialization Pin
Eduard Keilholz19-Jul-07 0:01
Eduard Keilholz19-Jul-07 0:01 
GeneralRe: Xml Serialization Pin
Martin#19-Jul-07 0:08
Martin#19-Jul-07 0:08 
QuestionTreeview problem Pin
MoeInsairat18-Jul-07 21:36
MoeInsairat18-Jul-07 21:36 

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.