Click here to Skip to main content
15,912,069 members
Home / Discussions / C#
   

C#

 
GeneralRe: Accessing control from seperate class Pin
led mike2-Nov-07 5:22
led mike2-Nov-07 5:22 
GeneralRe: Accessing control from seperate class Pin
oceanexplorer2-Nov-07 5:35
oceanexplorer2-Nov-07 5:35 
GeneralRe: Accessing control from seperate class Pin
led mike2-Nov-07 7:09
led mike2-Nov-07 7:09 
QuestionC# based web service: Referring IP address? Pin
Jerry Evans2-Nov-07 4:03
Jerry Evans2-Nov-07 4:03 
AnswerRe: C# based web service: Referring IP address? Pin
Jerry Evans2-Nov-07 4:53
Jerry Evans2-Nov-07 4:53 
QuestionExecute script with trasaction on firebird database server Pin
Razvan Dimescu2-Nov-07 3:41
Razvan Dimescu2-Nov-07 3:41 
AnswerRe: Execute script with trasaction on firebird database server Pin
Razvan Dimescu2-Nov-07 4:46
Razvan Dimescu2-Nov-07 4:46 
QuestionThreading and cross-threading Pin
oceanexplorer2-Nov-07 3:16
oceanexplorer2-Nov-07 3:16 
Hi,

I have created a windows form the contains a button and a list box. When the button is clicked it fires the following code,

 <br />
Migration.Begin();<br />
thread = new Thread(new ThreadStart(Migration.Begin));<br />
thread.Start();<br />


Migration is a seperate class that is executed on a new thread as it will be a labour intensive task and I want the UI to remain usable.

However within the migration module I want to be able to call back to the thread that created the UI and have it append a message to the listbox.

So intially in the UI class I added a delgate which called a seperate function to add a line to the listbox:

<br />
public static LoggerListDelegate loggerListDelegate;       <br />
        <br />
public Logger()<br />
{<br />
    InitializeComponent();<br />
    loggerListDelegate = new LoggerListDelegate(AddLine);<br />
}<br />


And the function addline was as follows:

<br />
public void AddLine(string line)<br />
{<br />
    lstLogger.Items.Add(DateTime.Now.ToLongTimeString() + ": " + line);           <br />
}<br />


I then called this from the Migration using the following:

<br />
Logger.loggerListDelegate.BeginInvoke("******Migration has begun******",null,null);<br />


This however is giving me an issue that it is not thread safe as I am trying to invoke on different thread the list was created on.

So my understanding is that I would really need to call the Listbox invoke method, e.g.

lstLogger.Invoke(delegate, objects)

If that's correct how do I access the lstLogger from my Migration class in order to invoke it?

If this is not right how do I go about making it threadsafe?

Many many many thanks

Paul
AnswerRe: Threading and cross-threading Pin
Daniel Grunwald2-Nov-07 3:29
Daniel Grunwald2-Nov-07 3:29 
GeneralRe: Threading and cross-threading Pin
oceanexplorer2-Nov-07 3:37
oceanexplorer2-Nov-07 3:37 
AnswerCan anyone still answer this? Pin
oceanexplorer2-Nov-07 5:13
oceanexplorer2-Nov-07 5:13 
AnswerRe: Threading and cross-threading Pin
m@u2-Nov-07 6:29
m@u2-Nov-07 6:29 
QuestionXP ICONS Pin
half-life2-Nov-07 2:41
half-life2-Nov-07 2:41 
AnswerRe: XP ICONS Pin
Pete O'Hanlon2-Nov-07 3:31
mvePete O'Hanlon2-Nov-07 3:31 
GeneralRe: XP ICONS [modified] Pin
half-life2-Nov-07 5:00
half-life2-Nov-07 5:00 
QuestionHow can I check if a node in a treeview allready exist ? Pin
Kenth Ringsby2-Nov-07 2:31
Kenth Ringsby2-Nov-07 2:31 
AnswerRe: How can I check if a node in a treeview allready exist ? Pin
Giorgi Dalakishvili2-Nov-07 2:53
mentorGiorgi Dalakishvili2-Nov-07 2:53 
GeneralRe: How can I check if a node in a treeview allready exist ? Pin
c0ax_lx2-Nov-07 3:00
c0ax_lx2-Nov-07 3:00 
GeneralRe: How can I check if a node in a treeview allready exist ? Pin
Kenth Ringsby2-Nov-07 9:57
Kenth Ringsby2-Nov-07 9:57 
QuestionString.Format question Pin
Seraph_summer2-Nov-07 2:18
Seraph_summer2-Nov-07 2:18 
AnswerRe: String.Format question Pin
snorkie2-Nov-07 4:57
professionalsnorkie2-Nov-07 4:57 
QuestionHow to convert mm/dd/yy to dd/mm/yy Pin
Arif patel2-Nov-07 1:47
Arif patel2-Nov-07 1:47 
AnswerRe: How to convert mm/dd/yy to dd/mm/yy Pin
Pete O'Hanlon2-Nov-07 1:52
mvePete O'Hanlon2-Nov-07 1:52 
GeneralRe: How to convert mm/dd/yy to dd/mm/yy Pin
Arif patel2-Nov-07 2:06
Arif patel2-Nov-07 2:06 
GeneralRe: How to convert mm/dd/yy to dd/mm/yy Pin
Pete O'Hanlon2-Nov-07 2:09
mvePete O'Hanlon2-Nov-07 2:09 

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.