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

C#

 
QuestionRegarding Activex Control Pin
Member 477486810-Jun-08 0:45
Member 477486810-Jun-08 0:45 
AnswerRe: Regarding Activex Control Pin
Arjun Marwaha10-Jun-08 0:53
Arjun Marwaha10-Jun-08 0:53 
GeneralRe: Regarding Activex Control Pin
Member 477486810-Jun-08 19:06
Member 477486810-Jun-08 19:06 
QuestionREfresging Form While process is running Pin
MumbleB9-Jun-08 23:57
MumbleB9-Jun-08 23:57 
AnswerRe: REfresging Form While process is running Pin
Giorgi Dalakishvili10-Jun-08 0:12
mentorGiorgi Dalakishvili10-Jun-08 0:12 
GeneralRe: REfresging Form While process is running Pin
MumbleB10-Jun-08 1:44
MumbleB10-Jun-08 1:44 
GeneralRe: REfresging Form While process is running Pin
Giorgi Dalakishvili10-Jun-08 1:56
mentorGiorgi Dalakishvili10-Jun-08 1:56 
GeneralRe: REfresging Form While process is running Pin
MumbleB10-Jun-08 5:44
MumbleB10-Jun-08 5:44 
Hi Giorgi. I ahve moved the code into a new thred but I get an error on the progressbar. Error details as below.

System.InvalidOperationException was unhandled<br />
  Message="Cross-thread operation not valid: Control 'progressBar1' accessed from a thread other than the thread it was created on."<br />
  Source="System.Windows.Forms"<br />
  StackTrace:<br />
       at System.Windows.Forms.Control.get_Handle()<br />
       at System.Windows.Forms.Control.SendMessage(Int32 msg, Int32 wparam, Int32 lparam)<br />
       at System.Windows.Forms.ProgressBar.set_Maximum(Int32 value)<br />
       at NomConv.Form1.RunExcel() in C:\Documents and Settings\mumbleb\My Documents\Visual Studio 2008\Projects\NomConv\NomConv\Form1.cs:line 118<br />
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)<br />
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)<br />
       at System.Threading.ThreadHelper.ThreadStart()<br />
  InnerException: 


Now, this is what I'm doing. I'm calling the Thread in the button event as below.

        private void btnRun_Click(object sender, EventArgs e)
        {
            Thread excelrun = new Thread(RunExcel);
            excelrun.Start();
            //Set up the ProgressBar Properties

            lblPercent2.Visible = true;
            lblRecordProcessed.Visible = true;
            lblProgText.Visible = true;
            progressBar1.Visible = true;
            lblProgress.Visible = true;
}


And then the code from the new class.

private void RunExcel()
{
    string filepath;
    filepath = txtboxSelectTxtFile.Text;
    FileHelperEngine<ReadFile> engine = new FileHelperEngine<ReadFile>();
    engine.ErrorManager.ErrorMode = ErrorMode.SaveAndContinue;

    ReadFile[] res = engine.ReadFile(filepath, 1);
    ReadFile[] mes = engine.ReadFile(filepath);

    //Progress Bar stuff was here
    int progrval = 0;
    progrval = progressBar1.Value;
    progressBar1.Minimum = 0;
    progressBar1.Maximum = engine.TotalRecords;


Any idea what I should do? I have tried moving the code for the progressbar around and I get all sorts of errors on it.

Excellence is doing ordinary things extraordinarily well.

GeneralRe: REfresging Form While process is running [modified] Pin
Giorgi Dalakishvili10-Jun-08 6:03
mentorGiorgi Dalakishvili10-Jun-08 6:03 
GeneralRe: REfresging Form While process is running Pin
MumbleB10-Jun-08 7:07
MumbleB10-Jun-08 7:07 
GeneralRe: REfresging Form While process is running Pin
Giorgi Dalakishvili10-Jun-08 7:35
mentorGiorgi Dalakishvili10-Jun-08 7:35 
QuestionSplash Screen Form Pin
see_seA9-Jun-08 23:57
see_seA9-Jun-08 23:57 
AnswerRe: Splash Screen Form Pin
leppie10-Jun-08 23:46
leppie10-Jun-08 23:46 
GeneralRe: Splash Screen Form Pin
see_seA11-Jun-08 0:02
see_seA11-Jun-08 0:02 
Questionproblem with output parameter Pin
Mr.Kode9-Jun-08 23:50
Mr.Kode9-Jun-08 23:50 
AnswerRe: problem with output parameter Pin
Ashfield10-Jun-08 1:25
Ashfield10-Jun-08 1:25 
AnswerRe: problem with output parameter Pin
Eslam Afifi10-Jun-08 2:30
Eslam Afifi10-Jun-08 2:30 
QuestionAdding VB Code to ThisWorkbook using C# problem Pin
Yasser Sobhdel9-Jun-08 23:26
Yasser Sobhdel9-Jun-08 23:26 
QuestionByte[] type in datagrid gives error. Pin
topcatalpha9-Jun-08 23:08
topcatalpha9-Jun-08 23:08 
QuestionFetching files Pin
shriya_179-Jun-08 23:04
shriya_179-Jun-08 23:04 
AnswerRe: Fetching files Pin
Ashfield9-Jun-08 23:28
Ashfield9-Jun-08 23:28 
QuestionGet filename from windows explorer right menu? Pin
Abdul Gafoor9-Jun-08 22:39
Abdul Gafoor9-Jun-08 22:39 
AnswerRe: Get filename from windows explorer right menu? Pin
Giorgi Dalakishvili9-Jun-08 22:45
mentorGiorgi Dalakishvili9-Jun-08 22:45 
QuestionMS Office 2007 - Server Requirements Pin
newc19-Jun-08 22:30
newc19-Jun-08 22:30 
AnswerRe: MS Office 2007 - Server Requirements Pin
Mike Dimmick10-Jun-08 2:17
Mike Dimmick10-Jun-08 2:17 

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.