Click here to Skip to main content
15,914,452 members
Home / Discussions / C#
   

C#

 
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 
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 
hehe this is where it gets complicated. i haven't done much with threads at all but i also came across this problem when writing a "popup" class. as you may have noticed you were starting another thread for the listening method. the thread where all the controls remain to is the one where you started the second thread from. sounds complicated but it isn't.

now you have to communicate from one thread to another. you can do this by using the invoke procedure of the control. i just will give you the sourcecode and you will see what will happen Smile | :)

instead of using the regular add method of the listbox you have to use the listboxs "invoke" method.

Put this code somewhere inside your class:
<br />
private delegate void AddTextInvoker(string textToAdd);<br />


Now replace the line of code where you want to add an item to the listbox with these lines:
<br />
object [] invokeParams = {"TextOrItemToAdd"};<br />
lbReceived.Invoke(new AddTextInvoker(AddTextToListbox), invokeParams);<br />


finally add the "AddTextToListbox" method to your class and make it add an item to the listbox:
<br />
private void AddTextToListbox(string textToAdd)<br />
{<br />
lbReceived.Add(textToAdd);<br />
}<br />


but be careful with invoking anything. it happened to me that one thread disposed a control and another one tried to change on of its properties - that will result in an exception. you should try to make yourself more familiar with threads since my knowledge ends here too. maybe someone else could tell you WHY its not possible to do a cross-thread operation and stuff - for now you should be able to solve your problem :P

// edit: sorry code snippet did not work because it just was wrong - now it should work :P


-- modified at 9:00 Tuesday 10th October, 2006
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 
GeneralRe: isnumeric in c# Pin
Amar Chaudhary10-Oct-06 0:17
Amar Chaudhary10-Oct-06 0:17 
GeneralRe: isnumeric in c# Pin
rah_sin10-Oct-06 0:29
professionalrah_sin10-Oct-06 0:29 

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.