Click here to Skip to main content
15,921,212 members
Home / Discussions / C#
   

C#

 
QuestionRemoving shim and placing VSTO. Pin
SRKSHOME11-Sep-09 3:38
SRKSHOME11-Sep-09 3:38 
QuestionFTPS SSL/TLS Issue on Some Computers Pin
SimpleData11-Sep-09 2:28
SimpleData11-Sep-09 2:28 
QuestionC# Background Worker losing variable value in Progress Pin
Wheels01211-Sep-09 2:15
Wheels01211-Sep-09 2:15 
AnswerRe: C# Background Worker losing variable value in Progress Pin
DaveyM6911-Sep-09 2:56
professionalDaveyM6911-Sep-09 2:56 
GeneralRe: C# Background Worker losing variable value in Progress Pin
Wheels01211-Sep-09 3:48
Wheels01211-Sep-09 3:48 
GeneralRe: C# Background Worker losing variable value in Progress Pin
DaveyM6911-Sep-09 4:14
professionalDaveyM6911-Sep-09 4:14 
AnswerRe: C# Background Worker losing variable value in Progress Pin
Alan N11-Sep-09 2:56
Alan N11-Sep-09 2:56 
AnswerRe: C# Background Worker losing variable value in Progress Pin
DaveyM6911-Sep-09 3:10
professionalDaveyM6911-Sep-09 3:10 
When trying to find the solution to a problem such as this I often set up a quickie test project with all the irrelevant stuff removed such as...
using System.ComponentModel;
using System.Windows.Forms;

namespace TestBGW
{
    public partial class Form1 : Form
    {
        private BackgroundWorker backgroundWorker;
        private string testString;

        public Form1()
        {
            InitializeComponent();
            backgroundWorker = new BackgroundWorker();
            backgroundWorker.WorkerReportsProgress = true;
            backgroundWorker.DoWork += new DoWorkEventHandler(backgroundWorker_DoWork);
            backgroundWorker.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker_ProgressChanged);
            testString = "A";
            backgroundWorker.RunWorkerAsync(testString);
        }

        void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            string passedThrough = (string)e.Argument;
            passedThrough = "B";
            backgroundWorker.ReportProgress(0, passedThrough);
        }

        void backgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            MessageBox.Show(string.Format("{0} - {1}", testString, e.UserState));
        }
    }
}
By the way, if you are accessing values that are not local to the DoWork handler inside it, you should aquire a lock on them first

Dave

Generic BackgroundWorker - My latest article!
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Why are you using VB6? Do you hate yourself? (Christian Graus)

QuestionDBNull error Pin
kanchoette11-Sep-09 1:38
kanchoette11-Sep-09 1:38 
AnswerRe: DBNull error Pin
monstale11-Sep-09 2:22
monstale11-Sep-09 2:22 
AnswerRe: DBNull error Pin
J4amieC11-Sep-09 2:22
J4amieC11-Sep-09 2:22 
AnswerRe: DBNull error Pin
PIEBALDconsult11-Sep-09 4:28
mvePIEBALDconsult11-Sep-09 4:28 
QuestionHow do I read in a h246 .mp4 file and change some hex in the file and then save the file back out? Pin
thestonefox11-Sep-09 1:05
thestonefox11-Sep-09 1:05 
AnswerRe: How do I read in a h246 .mp4 file and change some hex in the file and then save the file back out? Pin
stancrm11-Sep-09 1:22
stancrm11-Sep-09 1:22 
QuestionC# Excel. Find a specific cell and write in string data into the cell to the right of the found cell. [modified] Pin
gjx_junxian198911-Sep-09 0:16
gjx_junxian198911-Sep-09 0:16 
QuestionWMI Pin
moein.serpico10-Sep-09 23:57
moein.serpico10-Sep-09 23:57 
AnswerRe: WMI Pin
dan!sh 11-Sep-09 0:19
professional dan!sh 11-Sep-09 0:19 
AnswerRe: WMI Pin
moein.serpico11-Sep-09 0:29
moein.serpico11-Sep-09 0:29 
GeneralRe: WMI Pin
Henry Minute11-Sep-09 0:34
Henry Minute11-Sep-09 0:34 
AnswerRe: WMI Pin
moein.serpico11-Sep-09 0:38
moein.serpico11-Sep-09 0:38 
GeneralRe: WMI Pin
Henry Minute11-Sep-09 0:47
Henry Minute11-Sep-09 0:47 
GeneralRe: WMI Pin
moein.serpico11-Sep-09 1:52
moein.serpico11-Sep-09 1:52 
GeneralRe: WMI Pin
stancrm11-Sep-09 0:36
stancrm11-Sep-09 0:36 
GeneralRe: WMI Pin
Dave Kreskowiak11-Sep-09 4:19
mveDave Kreskowiak11-Sep-09 4:19 
Questionproblems about how to cancel auto play from an application Pin
smilefishcc10-Sep-09 23:45
smilefishcc10-Sep-09 23:45 

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.