Click here to Skip to main content
15,918,889 members
Home / Discussions / C#
   

C#

 
Questioncross-threading problem Pin
suck12320-May-07 22:31
suck12320-May-07 22:31 
hi,
I've got this part of code
<br />
public delegate void DellagacjaVoid();<br />
<br />
        public void pingowanie()<br />
        {<br />
            if (this.InvokeRequired)<br />
            {<br />
                DellagacjaVoid delegacja = new DellagacjaVoid(pingowanie);<br />
                this.Invoke(delegacja);<br />
            }<br />
<br />
            string sciezka = "plik.txt";<br />
            if (File.Exists(sciezka))<br />
            {                               <br />
                FileStream fs = new FileStream(sciezka, FileMode.Open, FileAccess.Read);<br />
                StreamReader reader = new StreamReader(fs);<br />
                string linia = reader.ReadLine();<br />
                linia = null;<br />
                while ((linia=reader.ReadLine()) != null)<br />
                {<br />
                    try<br />
                    {                        <br />
                        richTextBox1.Text += linia + "\n";<br />
                    }<br />
                    catch (Exception ex)<br />
                    {<br />
                        MessageBox.Show(ex.Message);<br />
                    }<br />
                }<br />
                reader.Close();<br />
            }<br />
        }<br />
<br />
private void button1_Click(object sender, EventArgs e)<br />
        {<br />
            Thread watek = new Thread(pingowanie);<br />
            watek.Start();            <br />
        }<br />


the thing is that the content i read to the richtextbox alright, as many lines as there are in the txt file but also I get as many exeptions as number of lines with the text like this:
http://img444.imageshack.us/img444/6911/88524168zy6.png[^]

can someone help?
AnswerRe: cross-threading problem Pin
Bekjong20-May-07 23:21
Bekjong20-May-07 23:21 
AnswerRe: cross-threading problem Pin
PandemoniumPasha21-May-07 0:08
PandemoniumPasha21-May-07 0:08 
QuestionHow can I write text file on web application? [modified] Pin
Junior Boy20-May-07 21:34
Junior Boy20-May-07 21:34 
AnswerRe: How can I write text file on web application? Pin
Christian Graus20-May-07 21:46
protectorChristian Graus20-May-07 21:46 
GeneralRe: How can I write text file on web application? Pin
Junior Boy20-May-07 22:36
Junior Boy20-May-07 22:36 
GeneralRe: How can I write text file on web application? Pin
Christian Graus20-May-07 23:14
protectorChristian Graus20-May-07 23:14 
QuestionStange crashes of an application Pin
J. Holzer20-May-07 21:29
J. Holzer20-May-07 21:29 
AnswerRe: Stange crashes of an application Pin
Manoj Kumar Rai20-May-07 22:36
professionalManoj Kumar Rai20-May-07 22:36 
GeneralRe: Stange crashes of an application Pin
J. Holzer20-May-07 23:27
J. Holzer20-May-07 23:27 
QuestionDownloading XML File Pin
Vineed20-May-07 21:00
Vineed20-May-07 21:00 
AnswerRe: Downloading XML File Pin
Dave Herren21-May-07 11:36
Dave Herren21-May-07 11:36 
Questionabout event question.I need help,thanks. Pin
jason_mf20-May-07 20:45
jason_mf20-May-07 20:45 
AnswerRe: about event question.I need help,thanks. Pin
Expert Coming20-May-07 20:51
Expert Coming20-May-07 20:51 
GeneralRe: about event question.I need help,thanks. Pin
jason_mf20-May-07 21:02
jason_mf20-May-07 21:02 
GeneralRe: about event question.I need help,thanks. Pin
PandemoniumPasha20-May-07 21:32
PandemoniumPasha20-May-07 21:32 
GeneralRe: about event question.I need help,thanks. Pin
jason_mf21-May-07 19:55
jason_mf21-May-07 19:55 
GeneralRe: about event question.I need help,thanks. Pin
blackjack215020-May-07 21:32
blackjack215020-May-07 21:32 
GeneralRe: about event question.I need help,thanks. Pin
jason_mf20-May-07 22:15
jason_mf20-May-07 22:15 
QuestionSQL and Progress Updates Pin
Expert Coming20-May-07 20:44
Expert Coming20-May-07 20:44 
AnswerRe: SQL and Progress Updates Pin
Dave Herren21-May-07 3:41
Dave Herren21-May-07 3:41 
Questiondelete record from Datagrid view which check box are checked Pin
kushak_manoj20-May-07 20:08
kushak_manoj20-May-07 20:08 
AnswerRe: delete record from Datagrid view which check box are checked Pin
Manoj Kumar Rai20-May-07 21:45
professionalManoj Kumar Rai20-May-07 21:45 
QuestionRegular Expression Match Grouping Pin
nasambur20-May-07 19:56
nasambur20-May-07 19:56 
QuestionDAAB- SQLHelper ExecuteDataSet vs Fill Method Pin
K.P.Kannan20-May-07 18:29
K.P.Kannan20-May-07 18: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.