473,322 Members | 1,259 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

BackgroundWorker Does Not Fire RunWorkerCompleted


I have a small app that I am working with to create LDIF files from
text files. I have a pictureBox that has an animated GIF that will
appear on the form when the LDIF are being created. The pictureBox
appears and the GIF is there, but it does not stop when called. So
when I debug, the RunWorkerCompleted event never fires. Is there
anything in my code that is obvious as to why.

[code]

private void createLDIF_btn_Click(object sender, EventArgs e)
{
ldifCreate_lbl.Visible = false;
string saveFolder2;
if (addMembers_chk.Checked == false &&
addGroup_chk.Checked == false)
{
MessageBox.Show("Please Check At Least One Option");
return;
}
if (folderBrowserDialog2.ShowDialog() == DialogResult.OK)
{
if ((saveFolder2 = folderBrowserDialog2.SelectedPath) !
= null)
{
pictureBox1.Visible = true;
backgroundWorker1.RunWorkerAsync(saveFolder2);
}
}
}

private void createLDIFs(string saveFolder2)
{
for (int i = 0; i < listBox1.Items.Count; i++)
{
string sLine1;

using (StreamReader sr1 = new
StreamReader(listBox1.Items[i].ToString()))
{
StreamWriter addgroupLDF =
File.AppendText(saveFolder2.ToString() + "\\RACF_ADDGROUP_LDF.ldf"); //
enter the full path for the output file
StreamWriter connectLDF =
File.AppendText(saveFolder2.ToString() + "\\RACF_CONNECT_LDF.ldf"); //
enter the full path for the output file
StreamWriter addsdLDF =
File.AppendText(saveFolder2.ToString() + "\\RACF_ADDSD_LDF.ldf"); //
enter the full path for the output file

while ((sLine1 = sr1.ReadLine()) != null)
{
string owner = @"(.\b(owner)\b\W.*?\W)";
string data = @"(.\b(data)\b\W\W.*?\W\W)";
string superGroup = @"(.\b(supgroup)\b\W.*?
\W)";
string groupReg = @"(.\b(group)\b\W.*\s.*?
\W)";

Match ownerMatch = Regex.Match(sLine1, owner);
Match dataMatch = Regex.Match(sLine1, data);
Match superGroupMatch = Regex.Match(sLine1,
superGroup);
Match groupMatch = Regex.Match(sLine1,
groupReg);

string owner1 = ownerMatch.Value.ToString();
string dataStr =
StringHelpers.Between(dataMatch.Value.ToString(), '\'', '\'');
string supGroupStr =
superGroupMatch.Value.ToString();
string groupStr =
StringHelpers.Between(groupMatch.Value.ToString(), '(', ')').Replace("
", "");
string grpName = StringHelpers.Between(sLine1,
' ', ' ');

if (addGroup_chk.Checked)
{
if (sLine1.StartsWith("addgroup"))
{

if (grpName.Contains("#"))
{
addgroupLDF.WriteLine("dn: cn=\\"
+ grpName + ",cn=Enterprise Server User Groups,cn=micro
focus,cn=program data,dc=test,dc=com");
}
else
{
addgroupLDF.WriteLine("dn: cn=" +
grpName + ",cn=Enterprise Server User Groups,cn=micro focus,cn=program
data,dc=test,dc=com");
}
addgroupLDF.WriteLine("changetype:
add");

addgroupLDF.WriteLine("adminDisplayName: " + grpName);
addgroupLDF.WriteLine("objectClass:
microfocus-MFDS-Group");
addgroupLDF.WriteLine("microfocus-MFDS-
UID: " + grpName);
if (dataStr != "")
{

addgroupLDF.WriteLine("description: " + dataStr);
}
addgroupLDF.WriteLine();
}
}

if (addMembers_chk.Checked)
{
if (sLine1.StartsWith("connect"))
{
string userName =
StringHelpers.Between(sLine1, ' ', ' ');
if (groupStr.Contains("#"))
{
connectLDF.WriteLine("dn: cn=\\" +
groupStr + ",cn=Enterprise Server User Groups,cn=micro
focus,cn=program data,dc=test,dc=com");
}
else
{
connectLDF.WriteLine("dn: cn=" +
groupStr + ",cn=Enterprise Server User Groups,cn=micro
focus,cn=program data,dc=test,dc=com");
}
connectLDF.WriteLine("changetype:
modify");
connectLDF.WriteLine("add: microfocus-
MFDS-Group-Member");
connectLDF.WriteLine("microfocus-MFDS-
Group-Member: " + userName);
connectLDF.WriteLine("-");
connectLDF.WriteLine();
}
}

if (sLine1.StartsWith("addsd"))
{
string resourceName =
StringHelpers.Between(sLine1, '\'', '\'');
addsdLDF.WriteLine("dn: cn=" +
resourceName + ",cn=Enterprise Server Resources,cn=micro
focus,cn=program data,dc=test,dc=com");
addsdLDF.WriteLine("changetype: add");
addsdLDF.WriteLine("objectClass:
microfocus-MFDS-Resource");
addsdLDF.WriteLine("microfocus-MFDS-
Resource-Class: ");
addsdLDF.WriteLine();
}
}
sr1.Close();
addgroupLDF.Close();
connectLDF.Close();
addsdLDF.Close();
}
}
}

private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs
e)
{
createLDIFs(e.Argument.ToString());
}

private void backgroundWorker1_RunWorkerCompleted(object
sender, RunWorkerCompletedEventArgs e)
{
if (e.Error != null)
{
MessageBox.Show(e.Error.Message);
MessageBox.Show("Error");
}
else if (e.Cancelled)
{
MessageBox.Show("CANCELLED. ");
}
else
{
MessageBox.Show("Finished");
MessageBox.Show(e.Result.ToString());
}
}

Sep 7 '07 #1
1 4104
On Sep 7, 9:34 am, VAADADMIN <siegma...@verizon.netwrote:
I have a small app that I am working with to create LDIF files from
text files. I have a pictureBox that has an animated GIF that will
appear on the form when the LDIF are being created. The pictureBox
appears and the GIF is there, but it does not stop when called. So
when I debug, the RunWorkerCompleted event never fires. Is there
anything in my code that is obvious as to why.
First, since you don't show the designer code, just check to make sure
the event is still hooked up (g)

Second, it looks like you are accessing the gui components from the
background worker thread. That's bad, and can cause all sorts of
problems

Sep 7 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Matthias S. | last post by:
Hi, I've written a simple app which should just fetch some data from a database and render the results into a ListView. In order to not freeze the GUI, I'm using a BackgroundWorker. The...
3
by: chris | last post by:
hello, I can't seem to make this work: VS2005 I have a simple program that uses a backgroundworker control to execute a long process (webservice call) if that webservice call fails, i want to...
3
by: Pro1712 | last post by:
Hi, this may be a stupid question: How can I can call the DoWork-function of a BackgroundWorker synchronous? Or in other words: How can I extend the BackgroundWorker class with a function...
1
by: ditnooitlezen | last post by:
Hi, the (.NET 2.0) backgroundworker object has a DoWork method that operates in a background thread. When the DoWork method is finished the RunWorkerCompleted event is raised in the parent...
2
by: Bob Chambers | last post by:
Hi there, Can anyone comment on two apparent problems I've noticed with the "BackgroundWorker" class (e.g., the design pattern itself). The canonical examples always show a demonstration of a...
14
by: =?Utf-8?B?SXNobWFlbA==?= | last post by:
Hi, I have a form with a progress bar on it and wanted to use the BackgroundWorker to be able to update the progress. I looked at examples, run some of them, but in debug, when the code gets to...
5
by: Michael M. | last post by:
I have the following code (listed at bottom of post) that pings a small range of IP address to see which ones are alive. To speed things up a little I am trying to use more than one thread,...
9
by: RvGrah | last post by:
I'm completely new to using background threading, though I have downloaded and run through several samples and understood how they worked. My question is: I have an app whose primary form...
1
by: VAADADMIN | last post by:
I have a small app that I am working with to create LDIF files from text files. I have a pictureBox that has an animated GIF that will appear on the form when the LDIF are being created. The...
2
by: csharpula csharp | last post by:
Hello, I would like to know how can I fire events of background worker when I want to let know the main thread that the action finished and to send results. Is there a way to fire...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.