Click here to Skip to main content
15,894,646 members
Home / Discussions / C#
   

C#

 
Questionhow to take a screenShot using windows service Pin
Tariq Tario10-Oct-06 0:24
Tariq Tario10-Oct-06 0:24 
AnswerRe: how to take a screenShot using windows service Pin
g00fyman10-Oct-06 1:14
g00fyman10-Oct-06 1:14 
GeneralRe: how to take a screenShot using windows service Pin
Eric Dahlvang10-Oct-06 3:46
Eric Dahlvang10-Oct-06 3:46 
GeneralRe: how to take a screenShot using windows service Pin
Member 79236113-Jul-18 18:53
Member 79236113-Jul-18 18:53 
QuestionPassive/Active listening server Pin
The underdog9-Oct-06 23:53
The underdog9-Oct-06 23:53 
AnswerRe: Passive/Active listening server Pin
mikone10-Oct-06 0:01
mikone10-Oct-06 0:01 
GeneralRe: Passive/Active listening server Pin
The underdog10-Oct-06 0:26
The underdog10-Oct-06 0:26 
GeneralRe: Passive/Active listening server Pin
mikone10-Oct-06 0:56
mikone10-Oct-06 0:56 
okay, lets create a simple listening function and the eventhandlers for those buttons Smile | :)

<br />
// This variable indicates whether the listen method should keep listening or not ;)<br />
bool KeepListening = false;<br />
<br />
// This is the eventhandler for the "Start Listening" button.<br />
public void button_StartListen_click(object sender, EventArgs e)<br />
{<br />
KeepListening = true;<br />
System.Threading.Thread myListenThread = new System.Threading.Tread(new System.Threading.ThreadStart(Listen));<br />
myListenThread.Start();<br />
}<br />
<br />
// This is the eventhandler for the "Stop Listening" button.<br />
public void button_StopListen_click(object sender, EventArgs e)<br />
{<br />
KeepListening = false;<br />
}<br />
<br />
// This is the Listen method.<br />
private void Listen()<br />
{<br />
while (KeepListening)<br />
{<br />
// Put your "receiving code" in here...<br />
System.Threading.Thread.Sleep(10);<br />
}<br />
}<br />


Okay, thats how it could look like now lets see what exactly happens here.
If you click on the "Start Listening" Button, the method button_StartListen_Click is called and:
- Sets KeepListening to 'true'
- Initiates a new object of the Thread Class and pass one argument in its constructor.
- Starts the new Thread.

Now the thread is running in the background. The threads task is to call the method "Listen" with no arguments. When doing so the method won't exit until you click the "Stop Listening" button because of the loop.

If you click the "Stop Listening" button now the button_StopListen_Click method will:
- Sets KeepListening to 'false'

Setting the KeepListening variable to false will cause the loop condition (while (KeepListening)) to be not forfilled. This makes the method exit and the thread will do so too!

This is no explanation about threading since this is a very complex subject. You should start playing around with them because multithreading is what you want your application to do ;D

However, hope you understood what i was talking about - if the code example does not work i will start my ide and create a working example Wink | ;)
GeneralRe: Passive/Active listening server Pin
The underdog10-Oct-06 2:23
The underdog10-Oct-06 2:23 
GeneralRe: Passive/Active listening server [modified] Pin
mikone10-Oct-06 2:52
mikone10-Oct-06 2:52 
QuestionGarbage Collector Performence Pin
Mandaar Kulkarni9-Oct-06 22:57
Mandaar Kulkarni9-Oct-06 22:57 
AnswerRe: Garbage Collector Performence Pin
quiteSmart9-Oct-06 23:16
quiteSmart9-Oct-06 23:16 
AnswerRe: Garbage Collector Performence Pin
S. Senthil Kumar10-Oct-06 2:55
S. Senthil Kumar10-Oct-06 2:55 
QuestionTabPage Events do not fire w/ .Net1.1 Pin
Jeff Jordan9-Oct-06 22:21
Jeff Jordan9-Oct-06 22:21 
AnswerRe: TabPage Events do not fire w/ .Net1.1 Pin
quiteSmart9-Oct-06 22:46
quiteSmart9-Oct-06 22:46 
GeneralRe: TabPage Events do not fire w/ .Net1.1 Pin
Jeff Jordan9-Oct-06 23:06
Jeff Jordan9-Oct-06 23:06 
GeneralRe: TabPage Events do not fire w/ .Net1.1 Pin
mikone10-Oct-06 0:06
mikone10-Oct-06 0:06 
GeneralRe: TabPage Events do not fire w/ .Net1.1 Pin
Jeff Jordan10-Oct-06 0:15
Jeff Jordan10-Oct-06 0:15 
Questionisnumeric in c# Pin
Amar Chaudhary9-Oct-06 22:16
Amar Chaudhary9-Oct-06 22:16 
AnswerRe: isnumeric in c# Pin
mikone9-Oct-06 22:27
mikone9-Oct-06 22:27 
GeneralRe: isnumeric in c# Pin
Amar Chaudhary10-Oct-06 0:20
Amar Chaudhary10-Oct-06 0:20 
GeneralRe: isnumeric in c# Pin
Martin#10-Oct-06 1:58
Martin#10-Oct-06 1:58 
GeneralIve heard that before Pin
Ennis Ray Lynch, Jr.10-Oct-06 16:40
Ennis Ray Lynch, Jr.10-Oct-06 16:40 
GeneralOk checked the MSIL Pin
Ennis Ray Lynch, Jr.10-Oct-06 17:03
Ennis Ray Lynch, Jr.10-Oct-06 17:03 
AnswerRe: isnumeric in c# Pin
RanjithLogics9-Oct-06 22:32
RanjithLogics9-Oct-06 22:32 

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.