|
I've got a BackgroundWorker that's supposed to perform processing on a 1gb file, but the worker is completing immediately before it even gets to the processing code in the DoWork event handler.
When I put a breakpoint on the first line in the event handler, it tells me this:
Function evaluation disabled because a previous function evaluation timed out. You must continue execution to reenable function evaluation.<br />
What the hell does that mean?
I'm setting up the backgroundworker object like so:
encryptWorker = new BackgroundWorker();
encryptWorker.WorkerReportsProgress = true;
encryptWorker.WorkerSupportsCancellation = true;
encryptWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(encryptWorker_DoWork);
encryptWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(encryptWorker_RunWorkerCompleted);
encryptWorker.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(encryptWorker_ProgressChanged);
I'm calling it like so. I've set a breakpoint on the last line in this block and have verified that the nextFile object is valid:
FileItem nextFile = m_filesToProcess[0];
this.m_fileBeingProcessed = nextFile;
while (this.encryptWorker.IsBusy)
{
Thread.Sleep(500);
}
this.progressBar.Value = 0;
this.encryptWorker.RunWorkerAsync(nextFile);
The DoWork function looks like this:
private void encryptWorker_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker thisWorker = sender as BackgroundWorker;
FileItem fileItem = e.Argument as FileItem;
if (fileItem.Toggle == EncryptToggle.Encrypt)
{
switch (fileItem.EncryptType)
{
case "blah blah" :
{
FileEncryptor encryptor = new FileEncryptor(thisWorker, fileItem);
encryptor.EncryptFile();
}
break;
}
}
}
}
}
When I set a breakpoint on the first line of the function above, it takes a few seconds for the cursor to become available, and when I pressed F10 (or F11) to step over the line, none of the subsequent lines are executed, and the Completed event handler is called.
What have I done wrong?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
modified on Saturday, July 26, 2008 1:26 PM
|
|
|
|
|
Does your encryptWorker_RunWorkerCompleted ever get executed?
John Simmons / outlaw programmer wrote: encryptWorker.WorkerReportsProgress = true;
encryptWorker = new BackgroundWorker();
Did you mean to do that in that order?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: Does your encryptWorker_RunWorkerCompleted ever get executed?
Yes. It gets called and the code inside it executes. The progressChanged method never gets called though.
Mark Salsbery wrote: Did you mean to do that in that order?
Nah - cut/paste error (and I corrected the message).
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: Yes. It gets called and the code inside it executes.
and AsyncCompletedEventArgs.Error == null there?
John Simmons / outlaw programmer wrote: The progressChanged method never gets called though.
I guess if ReportProgress is never getting called then it wouldn't...
Is it a debugger issue? I can't reproduce it here.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: and AsyncCompletedEventArgs.Error == null there?
Error, userState, and Result are all null.
Mark Salsbery wrote: Is it a debugger issue? I can't reproduce it here.
I don't know. If I let it run without the debugger, it doesn't crash. If I try to run it under the debugger, all hell breaks loose.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: If I try to run it under the debugger, all hell breaks loose.
Hmm beats me - I'm on 2008.
FWIW here's my test code, stolen from the docs:
private System.ComponentModel.BackgroundWorker backgroundWorker1;
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
for (int i = 0; i < 5; i++)
{
Thread.Sleep(1000);
this.backgroundWorker1.ReportProgress(i * 20);
}
e.Result = string.Format("**** Result String!");
this.backgroundWorker1.ReportProgress(100);
System.Diagnostics.Trace.WriteLine("**** End of DoWork");
}
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
System.Diagnostics.Trace.WriteLine("**** RunWorkerCompleted");
if (e.Error != null)
{
System.Diagnostics.Trace.WriteLine(e.Error.Message);
}
else if (e.Cancelled)
{
System.Diagnostics.Trace.WriteLine("Canceled");
}
else
{
System.Diagnostics.Trace.WriteLine(e.Result.ToString());
}
}
private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
System.Diagnostics.Trace.WriteLine(string.Format("**** ProgressChanged {0}%", e.ProgressPercentage));
}
...
this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
this.backgroundWorker1.WorkerReportsProgress = true;
this.backgroundWorker1.WorkerSupportsCancellation = false;
this.backgroundWorker1.DoWork += new DoWorkEventHandler(backgroundWorker1_DoWork);
this.backgroundWorker1.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker1_RunWorkerCompleted);
this.backgroundWorker1.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker1_ProgressChanged);
this.backgroundWorker1.RunWorkerAsync();
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
BTW, why do you have the "while (this.encryptWorker.IsBusy)"
loop before the RunWorkerAsync() call?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi John,
does this[^] help? The first hit seems to give a kind of workaround...
|
|
|
|
|
I presume this is a Windows.Forms application?
|
|
|
|
|
Yes, it's windows forms app...
BTW, I'm using VS2005, and at this time, I can't switch to VS2008 (just heading off a suggestion to try VS2008).
BTW, even if I reduce the worker contents to its simplest form, I still get the problem.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Some of the properties in a class I was trying to use were not simple set/get properties. As soon as I change them, everything was okay.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
At least you've got it answered
|
|
|
|
|
I'm making some custom controls basically, just to control the look of stuff.
I have a "LookAndFeel" class which contains properties to keep the Font, BackColor, ForeColor and stuff consistent through out the app.
The Font and ForeColor are fine... the BackColor is doing something I don't understand.
I have this in a Button control and I set the BackColor in my class to MediumPurple... when I drop the button on a form, it is displaying the normal default gray. The property windows says it should be MediumPurple and in the designer it is clearly set to MediumPurple. Everything else is working except BackColor
What am I missing here?
Thanks.
|
|
|
|
|
It's really weird too... for like a split second after dropping the button, it is MediumPurple... then it changes to Gray.
I don't get it.
|
|
|
|
|
I'm not seeing that problem (in VS 2008).
Do other controls appear as expected?
|
|
|
|
|
Yes they do... I'm working in vs05. this is just weird.
Everything else I assign a value to works, except BackColor.
|
|
|
|
|
I just tried it in VS2005 with no trouble, so there must be something in your code.
At which point do you set the BackColor?
|
|
|
|
|
Hi...
The "UseVisualStyleBackColor" property we set to "True", set to "False" this works.
Thank you for the reply.
|
|
|
|
|
hi,
I used below code for get mht file from given URL.
But sometimes it dosn't work and wait.
CDO.Message msg = new CDO.MessageClass();
ADODB.Stream stm = null;
byte[] data;
msg.MimeFormatted = true;
msg.CreateMHTMLBody(givenUrl, CDO.CdoMHTMLFlags.cdoSuppressAll, "", "");
string path = destinationPath + "\\" + fileName;
stm = msg.GetStream();
stm.SaveToFile(path, ADODB.SaveOptionsEnum.adSaveCreateOverWrite);
msg = null;
stm.Close();
when I debugged the code I saw this error in:
msg
--[CDO.MessageClass]
---- all items has error
"Cannot evaluate expression because a native frame is on top of the call stack"
it was stuck at this line :
msg.CreateMHTMLBody(givenUrl, CDO.CdoMHTMLFlags.cdoSuppressAll, "", "");
are there any way to get if isTimeout or not?
thanx...
I want to fly but I don't have wings
modified on Saturday, July 26, 2008 11:18 AM
|
|
|
|
|
If you stop the code in the middle of unmanaged code, the debugger can't reach the items on the stack that is created by the managed objects because it doesn't know the size of the unmanaged stack frame. You have to step through the unmanaged code back into the managed code before the debugger can show you the contents of the stack.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Yes, you are right.
I got it.
I need timeout option, but there is no timeout property or parameter etc...
I tested again the code if it will stuck or won't.
It is still same but after 4-5 minutes it was aborted and it worked.
4-5 minutes is too long for me.
I will work with thousands url, I can't wait 5 minutes for each url.
How can it continue after 15 seconds?
Is it possible?
I want to fly but I don't have wings
|
|
|
|
|
guys,
i need help how to approach/any idea to generate a list of names in a random. what i mean is i have an excel file which has list of employee names then when i click a button. it will give a random group. for example. 50 names in 1 group. it will give a result in a text file.
thanks in advance. i really appreciate your help.
C# Coudou
Microsoft End User
2000-2008
******************************
The best things in life are free
******************************
|
|
|
|
|
What I have done for that sort of thing is to have another table with two columns; one for the IDs of records in the main table and populate the other column with random numbers.
When it's time to select records; clear out the table, populate the table, then query the table, sorting by the random number column, and use the first 50 (or whatever) IDs.
You could simply add a random number column to the main table, but my process was trickier than that.
|
|
|
|
|
hope this helps!
First, read all the names from the excel file, probably into an array.
then, use some randomizing technique, and maybe a loop, to select your group.
and lastly, while selecting, write the names to a text file.
He who goes for revenge must first dig two graves.
|
|
|
|
|
Creamboy wrote: then, use some randomizing technique
Riiight... isn't that the part he's asking about?
|
|
|
|