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

C#

 
AnswerRe: using kdtele for c# application Pin
Not Active4-Aug-09 6:18
mentorNot Active4-Aug-09 6:18 
AnswerRe: using kdtele for c# application Pin
N a v a n e e t h4-Aug-09 6:20
N a v a n e e t h4-Aug-09 6:20 
QuestionPassing C# variable to HTML page Pin
VengefulSakhmet4-Aug-09 5:16
VengefulSakhmet4-Aug-09 5:16 
AnswerRe: Passing C# variable to HTML page Pin
Not Active4-Aug-09 6:17
mentorNot Active4-Aug-09 6:17 
GeneralRe: Passing C# variable to HTML page Pin
VengefulSakhmet4-Aug-09 8:33
VengefulSakhmet4-Aug-09 8:33 
AnswerRe: Passing C# variable to HTML page Pin
Adam Maras4-Aug-09 8:49
Adam Maras4-Aug-09 8:49 
GeneralRe: Passing C# variable to HTML page Pin
VengefulSakhmet4-Aug-09 10:44
VengefulSakhmet4-Aug-09 10:44 
QuestionC# Problems with background worker - progress bar Pin
Wheels0124-Aug-09 5:00
Wheels0124-Aug-09 5:00 
Good morning all.

I am coming up with an error: Cross-thread operation not valid. Attempted to access from a thread other than the thread it was created on.

My code:
private void btnSubmit_Click(object sender, EventArgs e)
        {

            if (tbRACFID.Text == string.Empty)
            {
                MessageBox.Show("You must have a RACFID in order to continue.", "RACFID Field Validation", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                ff.ControlSetFocus(tbRACFID);
                return;
            }
            if (tbUserName.Text == string.Empty)
            {
                MessageBox.Show("You must have a User Name in order to continue.", "User Name Field Validation", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                ff.ControlSetFocus(tbUserName);
                return;
            }

            PwdSecurity p = new PwdSecurity();
            uipc = this.Parent as UIPCMainForm;
            string strContainer = cbEndUserDepart.SelectedValue.ToString() + tbRACFID.Text.ToLower();
            DAL d = new DAL(uipc.StrUserName, p.base64Decode(uipc.StrPassword));
 
            this.backgroundWorker1.RunWorkerAsync();

            btnReset.PerformClick();
        }

private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            PwdSecurity p = new PwdSecurity();
            uipc = this.Parent as UIPCMainForm;
            string strContainer = cbEndUserDepart.SelectedValue.ToString() + tbRACFID.Text.ToLower(); //ERROR Line
            DAL d = new DAL(uipc.StrUserName, p.base64Decode(uipc.StrPassword));

            BackgroundWorker worker = (BackgroundWorker)sender;

            //Obtain Propper Subnet IP Address based on the Router Type from the Routr table, and
            //the DMVPN Subnet Type from the SubntSize table

            string SubnetIPAddress = string.Empty;
            DataSet ds = new DataSet();
            ds = d.FillDropDowns(4); //Subnet Size IP
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                if (
                    dr["ROUTR_TYPE"].ToString() == cbRouter.Text &&
                    dr["LOC"].ToString() == cbLocation.SelectedValue.ToString())
                {
                    SubnetIPAddress = dr["SUBNT_IPADR"].ToString();
                }
            }

            d.importContainer(
            strContainer,
            tbUserName.Text,
            cbRouter.SelectedValue.ToString(),
            (int)arSubNetList[cbSubnet.SelectedIndex],
            cbSubnet.SelectedValue.ToString(),
            arDHCPOptionList[cbLocation.SelectedIndex].ToString(),
            arDHCPPolicyList[cbLocation.SelectedIndex].ToString(),
            SubnetIPAddress,
            arAllocationTemplateList[cbSubnet.SelectedIndex].ToString()
            );
  
        }

        private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            this.tsProgBar.Value = e.ProgressPercentage; 
            this.tslStatus.Text = e.UserState as string;
        }

        private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            this.tslStatus.Text = "Operation complete";
        }


Any ideas? I saw something online about Invoke. Thank you, WHEELS
AnswerRe: C# Problems with background worker - progress bar Pin
Luc Pattyn4-Aug-09 5:15
sitebuilderLuc Pattyn4-Aug-09 5:15 
GeneralRe: C# Problems with background worker - progress bar [modified] Pin
Druuler4-Aug-09 5:24
Druuler4-Aug-09 5:24 
GeneralRe: C# Problems with background worker - progress bar Pin
Luc Pattyn4-Aug-09 5:41
sitebuilderLuc Pattyn4-Aug-09 5:41 
GeneralRe: C# Problems with background worker - progress bar Pin
Wheels0124-Aug-09 5:42
Wheels0124-Aug-09 5:42 
QuestionHow to make sure a form is closed Pin
belzer4-Aug-09 4:31
belzer4-Aug-09 4:31 
AnswerRe: How to make sure a form is closed Pin
Super Lloyd4-Aug-09 5:09
Super Lloyd4-Aug-09 5:09 
AnswerRe: How to make sure a form is closed Pin
Luc Pattyn4-Aug-09 5:21
sitebuilderLuc Pattyn4-Aug-09 5:21 
GeneralRe: How to make sure a form is closed Pin
belzer4-Aug-09 5:42
belzer4-Aug-09 5:42 
GeneralRe: How to make sure a form is closed Pin
N a v a n e e t h4-Aug-09 6:18
N a v a n e e t h4-Aug-09 6:18 
GeneralRe: How to make sure a form is closed Pin
belzer4-Aug-09 6:33
belzer4-Aug-09 6:33 
QuestionHow to insert an image in a word file using C#-2008 Pin
csetopper_bhanu4-Aug-09 3:58
csetopper_bhanu4-Aug-09 3:58 
QuestionAbstract vs Interface... Pin
p_19604-Aug-09 3:54
p_19604-Aug-09 3:54 
AnswerRe: Abstract vs Interface... Pin
N a v a n e e t h4-Aug-09 4:04
N a v a n e e t h4-Aug-09 4:04 
QuestionGarbage Collector Pin
jpk4204-Aug-09 2:53
jpk4204-Aug-09 2:53 
AnswerRe: Garbage Collector Pin
Not Active4-Aug-09 3:09
mentorNot Active4-Aug-09 3:09 
AnswerRe: Garbage Collector Pin
N a v a n e e t h4-Aug-09 3:57
N a v a n e e t h4-Aug-09 3:57 
QuestionHow to diable the Context Menue using SHDocVw.InternetExplorer Pin
Jacobb Michael4-Aug-09 2:07
Jacobb Michael4-Aug-09 2:07 

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.