473,657 Members | 2,825 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

BackgroundWorke r Does Not Fire RunWorkerComple ted


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 RunWorkerComple ted 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.Ch ecked == false)
{
MessageBox.Show ("Please Check At Least One Option");
return;
}
if (folderBrowserD ialog2.ShowDial og() == DialogResult.OK )
{
if ((saveFolder2 = folderBrowserDi alog2.SelectedP ath) !
= null)
{
pictureBox1.Vis ible = true;
backgroundWorke r1.RunWorkerAsy nc(saveFolder2) ;
}
}
}

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

using (StreamReader sr1 = new
StreamReader(li stBox1.Items[i].ToString()))
{
StreamWriter addgroupLDF =
File.AppendText (saveFolder2.To String() + "\\RACF_ADDGROU P_LDF.ldf"); //
enter the full path for the output file
StreamWriter connectLDF =
File.AppendText (saveFolder2.To String() + "\\RACF_CONNECT _LDF.ldf"); //
enter the full path for the output file
StreamWriter addsdLDF =
File.AppendText (saveFolder2.To String() + "\\RACF_ADDSD_L DF.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(sLi ne1, owner);
Match dataMatch = Regex.Match(sLi ne1, data);
Match superGroupMatch = Regex.Match(sLi ne1,
superGroup);
Match groupMatch = Regex.Match(sLi ne1,
groupReg);

string owner1 = ownerMatch.Valu e.ToString();
string dataStr =
StringHelpers.B etween(dataMatc h.Value.ToStrin g(), '\'', '\'');
string supGroupStr =
superGroupMatch .Value.ToString ();
string groupStr =
StringHelpers.B etween(groupMat ch.Value.ToStri ng(), '(', ')').Replace("
", "");
string grpName = StringHelpers.B etween(sLine1,
' ', ' ');

if (addGroup_chk.C hecked)
{
if (sLine1.StartsW ith("addgroup") )
{

if (grpName.Contai ns("#"))
{
addgroupLDF.Wri teLine("dn: cn=\\"
+ grpName + ",cn=Enterp rise Server User Groups,cn=micro
focus,cn=progra m data,dc=test,dc =com");
}
else
{
addgroupLDF.Wri teLine("dn: cn=" +
grpName + ",cn=Enterp rise Server User Groups,cn=micro focus,cn=progra m
data,dc=test,dc =com");
}
addgroupLDF.Wri teLine("changet ype:
add");

addgroupLDF.Wri teLine("adminDi splayName: " + grpName);
addgroupLDF.Wri teLine("objectC lass:
microfocus-MFDS-Group");
addgroupLDF.Wri teLine("microfo cus-MFDS-
UID: " + grpName);
if (dataStr != "")
{

addgroupLDF.Wri teLine("descrip tion: " + dataStr);
}
addgroupLDF.Wri teLine();
}
}

if (addMembers_chk .Checked)
{
if (sLine1.StartsW ith("connect"))
{
string userName =
StringHelpers.B etween(sLine1, ' ', ' ');
if (groupStr.Conta ins("#"))
{
connectLDF.Writ eLine("dn: cn=\\" +
groupStr + ",cn=Enterp rise Server User Groups,cn=micro
focus,cn=progra m data,dc=test,dc =com");
}
else
{
connectLDF.Writ eLine("dn: cn=" +
groupStr + ",cn=Enterp rise Server User Groups,cn=micro
focus,cn=progra m data,dc=test,dc =com");
}
connectLDF.Writ eLine("changety pe:
modify");
connectLDF.Writ eLine("add: microfocus-
MFDS-Group-Member");
connectLDF.Writ eLine("microfoc us-MFDS-
Group-Member: " + userName);
connectLDF.Writ eLine("-");
connectLDF.Writ eLine();
}
}

if (sLine1.StartsW ith("addsd"))
{
string resourceName =
StringHelpers.B etween(sLine1, '\'', '\'');
addsdLDF.WriteL ine("dn: cn=" +
resourceName + ",cn=Enterp rise Server Resources,cn=mi cro
focus,cn=progra m data,dc=test,dc =com");
addsdLDF.WriteL ine("changetype : add");
addsdLDF.WriteL ine("objectClas s:
microfocus-MFDS-Resource");
addsdLDF.WriteL ine("microfocus-MFDS-
Resource-Class: ");
addsdLDF.WriteL ine();
}
}
sr1.Close();
addgroupLDF.Clo se();
connectLDF.Clos e();
addsdLDF.Close( );
}
}
}

private void backgroundWorke r1_DoWork(objec t sender, DoWorkEventArgs
e)
{
createLDIFs(e.A rgument.ToStrin g());
}

private void backgroundWorke r1_RunWorkerCom pleted(object
sender, RunWorkerComple tedEventArgs e)
{
if (e.Error != null)
{
MessageBox.Show (e.Error.Messag e);
MessageBox.Show ("Error");
}
else if (e.Cancelled)
{
MessageBox.Show ("CANCELLED. ");
}
else
{
MessageBox.Show ("Finished") ;
MessageBox.Show (e.Result.ToStr ing());
}
}

Sep 7 '07 #1
1 4132
On Sep 7, 9:34 am, VAADADMIN <siegma...@veri zon.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 RunWorkerComple ted 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
7386
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 arguments for the RunWorkerAsync are the Query to be executed and the Connectionstring. As a result I hoped I could return a SqlDataReader. The problem is, if I create the SqlDataReader within the
3
12105
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 raise an exception and display a messagebox. however no matter where i put the Try block to trap the error, it does not work.
3
9976
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 RunWorkerSync()?
1
2894
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 thread. Now I have in the backgroundworker's DoWork method a try catch finally block, like this: StreamReader sr = null;
2
5268
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 "Cancel" button handler invoking "BackgroundWorker.CancelAsync()" but two possible problems then arise: 1) What happens if the "Cancel" button handler is running around the same time that the worker thread is exiting. In this case, the worker...
14
6383
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 the do work method, it stops for a long while and then executes the first line of the method and the doesn't do anything else. What am i doing wrong?
5
5549
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, problem is instead of returning: 192.168.0.1 online
9
18019
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 will almost always lead to the user opening a certain child window that's fairly resource intensive to load. Is it possible to load this form in a backgroundworker and then use the Show method and hide method as necessary? Anyone know of
1
451
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 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. .ToString())) { StreamWriter addgroupLDF =
2
1856
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 RunWorkerCompletedEventArgs in events from background to main thread? Thank you
0
8403
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8316
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8737
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8509
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8610
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2735
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.