Click here to Skip to main content
15,913,709 members
Home / Discussions / C#
   

C#

 
AnswerRe: threading Pin
sumit70343-Nov-08 0:06
sumit70343-Nov-08 0:06 
QuestionListView and column header Pin
Sandeep Kalra2-Nov-08 22:45
Sandeep Kalra2-Nov-08 22:45 
QuestionLINQ DateTime Format Pin
u2envy122-Nov-08 22:44
u2envy122-Nov-08 22:44 
AnswerRe: LINQ DateTime Format Pin
Guffa2-Nov-08 22:49
Guffa2-Nov-08 22:49 
GeneralRe: LINQ DateTime Format Pin
u2envy122-Nov-08 23:14
u2envy122-Nov-08 23:14 
QuestionCSV FILE Pin
ndeza2-Nov-08 22:21
ndeza2-Nov-08 22:21 
QuestionNewbie threading questions (data exchange + shutdown) Pin
Metal762-Nov-08 21:46
Metal762-Nov-08 21:46 
AnswerRe: Newbie threading questions (data exchange + shutdown) Pin
N a v a n e e t h2-Nov-08 22:25
N a v a n e e t h2-Nov-08 22:25 
Metal76 wrote:
The main thread keeps a reference to the MyProtocol objects created, and uses the Data property to exchange data with the thread (with appropriate synchronization using lock to avoid race conditions). Is this ok? Is there any better approach?


Yeah. This would be OK.

Metal76 wrote:
Which is the correct way to shut down the connection threads?


I would add a Stop() method to MyProtocol class. See the below example
volatile bool canContinue = true;
public void HandleClient(){
   while(canContinue){
      ......
   }
}

public void Stop(){
   canContinue = false;
}
You need to call Stop on all the MyProtocol instances created.

Alternatively, you can make the thread as background.
MyProtocol protocol = new MyProtocol();
Thread thread = new Thread(new ThreadStart(protocol.HandleClient));
thread.IsBackground = true;
thread.Start();
So it ends when the main thread ends. But the first one would be the better choice.
GeneralRe: Newbie threading questions (data exchange + shutdown) Pin
Metal762-Nov-08 22:44
Metal762-Nov-08 22:44 
GeneralRe: Newbie threading questions (data exchange + shutdown) Pin
N a v a n e e t h2-Nov-08 23:25
N a v a n e e t h2-Nov-08 23:25 
AnswerRe: Newbie threading questions (data exchange + shutdown) Pin
Nicholas Butler3-Nov-08 0:17
sitebuilderNicholas Butler3-Nov-08 0:17 
GeneralRe: Newbie threading questions (data exchange + shutdown) Pin
Metal763-Nov-08 4:35
Metal763-Nov-08 4:35 
QuestionDataGridView ComboBox: Allowing user to type in a value NOT in the Items collection. Pin
David Fleming2-Nov-08 21:27
David Fleming2-Nov-08 21:27 
AnswerRe: DataGridView ComboBox: Allowing user to type in a value NOT in the Items collection. Pin
David Fleming2-Nov-08 21:47
David Fleming2-Nov-08 21:47 
GeneralRe: DataGridView ComboBox: Allowing user to type in a value NOT in the Items collection. Pin
Pedram Behroozi2-Nov-08 22:15
Pedram Behroozi2-Nov-08 22:15 
AnswerRe: DataGridView ComboBox: Allowing user to type in a value NOT in the Items collection. Pin
Patrick Etc.3-Nov-08 17:02
Patrick Etc.3-Nov-08 17:02 
QuestionProblem with checkboxes and click() (newbie) Pin
Matjaz-xyz2-Nov-08 21:26
Matjaz-xyz2-Nov-08 21:26 
AnswerRe: Problem with checkboxes and click() (newbie) Pin
TommyTomToms2-Nov-08 22:20
TommyTomToms2-Nov-08 22:20 
GeneralRe: Problem with checkboxes and click() (newbie) Pin
Matjaz-xyz2-Nov-08 22:22
Matjaz-xyz2-Nov-08 22:22 
GeneralRe: Problem with checkboxes and click() (newbie) Pin
TommyTomToms2-Nov-08 22:35
TommyTomToms2-Nov-08 22:35 
GeneralRe: Problem with checkboxes and click() (newbie) Pin
Matjaz-xyz2-Nov-08 22:37
Matjaz-xyz2-Nov-08 22:37 
GeneralRe: Problem with checkboxes and click() (newbie) Pin
TommyTomToms2-Nov-08 22:52
TommyTomToms2-Nov-08 22:52 
AnswerRe: Problem with checkboxes and click() (newbie) Pin
Pedram Behroozi2-Nov-08 22:47
Pedram Behroozi2-Nov-08 22:47 
GeneralRe: Problem with checkboxes and click() (newbie) Pin
Matjaz-xyz2-Nov-08 23:47
Matjaz-xyz2-Nov-08 23:47 
QuestionHow to Get Network systems hardwares information?? Pin
moharrami2-Nov-08 18:52
moharrami2-Nov-08 18:52 

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.