[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Passing a string through a BackgroundWorker's RunWorkerAsync

Posted on 2006-03-29
4
Medium Priority
?
676 Views
Last Modified: 2008-02-01
I have a Bacground Worker where it needs a string. I have put the string in the RunWorkerAsync function but when I try to cast the sender variable back to a string with the following line..

Calling method:

String^ arg=this->GenerateArg();
MessageBox::Show(arg);
this->threadPleaseWait->RunWorkerAsync(arg);

casting Method

String args = dynamic_cast<String^>(sender);

arg is a String^, I get what I expect in the message box but when casting the 'args' value is null
0
Comment
Question by:gilllyo
  • 2
4 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 1500 total points
ID: 16330334
You must extract argument from DoWorkEventArgs^ e parameter, I guess it should be:

String^ args = dynamic_cast<String^>(e->Argument);

See: DoWorkEventArgs.Argument Property
0
 
LVL 2

Expert Comment

by:Chokehold
ID: 16330655
HAve you tried to use safe_cast instead ?
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 16341964
BTW, sender is BackgroundWorker itself. You need to cast it to BackgroundWorker and use inside of DoWork function.
0
 

Author Comment

by:gilllyo
ID: 16348126
Thanks

I have fixed that up...
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question