473,387 Members | 1,431 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,387 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 4110
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.