|
Dear all,
Could anyone please help me with the following problem. I have a MainForm in my application. I call a background worker thread to do some work. This thread never finishes, so it will always run in the background and will be closed when the application closes. This works perfect. Then I open a new form from my main thread and in that form I call another backgroundworker. As long as backgroundworker 2 is running, backgroundworker 1 becomes unresponsive. The MainForm stays responsive, the newly opened form stays responsive, but the two backgroundworkers don't seem to like each other and seems to be competing over resources.
* MainForm - backgroundworker 1
* subForm - backgroundworker 2
When backgroundworker 2 is running, backgroundworker 1 becomes unresponsive until backgroundworker 2 is finished.
Weird huh ?
Kind regards,
|
|
|
|
|
Rick van Woudenberg wrote: Weird huh ?
No. It's called a race condition and is a common problem when novices try multi-threaded programming
What are these threads doing? Are they trying to utilize the same resources?
http://msdn.microsoft.com/en-us/library/1c9txz50.aspx[^]
only two letters away from being an asset
|
|
|
|
|
in form1 i got
menu : File option help
open fix
form2 fix
how can i access fix design window from form1-> menu-> fix. you know, you press and choice fix from option menu in form1 and form2 fix will be opened
thx. 
|
|
|
|
|
Read documentation from net on Menu control first, you come to know how to do it.
|
|
|
|
|
Double click on the menu button in your designer. This will create an EventHandler.
Inside the EventHandler, put the following code :
private void OpenFix_Click(object sender, System.EventArgs e)
{
Form2 fix = new Form2();
fix.Open();
}
|
|
|
|
|
please provide any sample code
|
|
|
|
|
Parent Form :
public ProgressBar pb;
private void openChild_Click(object sender, System.EventArgs e)
{
ChildForm cf = new ChildForm();
cf.pf = this;
cf.open();
}
Child Form :
public ParentForm pf;
private void runProgressBar_Click(object sender, System.EventArgs e)
{
for(int i = 0;i<100;i++)
{
pf.pb.Value++;
}
}
|
|
|
|
|
Ick, I hope that was intentionally ironic!
|
|
|
|
|
i want to update progressbar in Child form not in Parent form
|
|
|
|
|
Simplest method is to add events to your child form that the parent subscribes to when the form is created. You can then use these to notify the parent that the progress needs changing.
Any sample code? Here's Hello World as a Vax-11 macro[^]
|
|
|
|
|
Hi everyone!
I have got a problem with Chinese fonts displayed on Crystal Report pdf.
I have these fonts installed on the server system(East Asian language pack enabled) and I change the *.rpt file font in runtime, using Ms Song font...but when I generate pdf this font is not displaying(Sans serif have appeared instead of MS Song ) but the font of *.rpt has been changed to Ms Song I have checked it.
Did anyone have such problems?
I'll be very appreciated for any help!
|
|
|
|
|
Why cant i do this? The value of "args" will be of similar format to the value i assigned to it. Im getting a "Index was outside the bounds of the array" error
static void Main(string[] args)
{
args[0] = "FrGbWOfvwO0=";
}
|
|
|
|
|
I guess the args is not initialized with any length of you don't start your application with any arguments. Why do you want to add values to the args array inside your code anyway?
|
|
|
|
|
Because it would be pointless ? The args collection is passed in, and exists only inside this method, why would you have any desire to change it ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
There is no element in the array args if you don't run the program with a command-line parameter. Therefore, args[0] does not exist. 0 is out of range.
|
|
|
|
|
In a recursive function for traversing a tree nodes , I want to invoke a function for the last child of a parent node( including all its grandchilds ). I have not found a technique for finding that node in the recursive function .
Any help ?
Thanks in advance.
|
|
|
|
|
List<TreeNode> nodeList = new List<TreeNode>();
private List<TreeNode> GetChildNodes(TreeNode treeNode)
{
foreach (TreeNode oNode in treeNode.Nodes)
{
nodeList.Add(oNode);
if (oNode.Nodes.Count > 0)
{
GetChildNodes(oNode);
}
else {
// this is the last node
}
}
return nodeList;
}
This would give you list of nodes in order as they would appear in expanded tree view.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
modified on Friday, October 23, 2009 6:39 AM
|
|
|
|
|
How to find the last grandchild of a parent node. All nodes have just one last grandchild.
in the following example node "node1_child3_child3" is the last grandchild of node1. Then how can I recognize that node in the recursive function ? What technique can I use ?
----node1
node1_child1
node1_child2
node1_child2_child1
node1_child2_child2
node1_child3
node1_child3_child1
node1_child3_child2
node1_child3_child3
modified on Friday, October 23, 2009 6:53 AM
|
|
|
|
|
If you need just the last node, change the return type of the method to treenode and use following code:
nodeList.Add(treeNode);
if (treeNode.Nodes.Count > 0) {
treeNode = GetChildNodes(treeNode.Nodes[treeNode.Nodes.Count - 1]);
}
return treeNode;
If you need complete heirarchy, you the following:
nodeList.Add(treeNode);
if (treeNode.Nodes.Count > 0) {
GetChildNodes(treeNode.Nodes[treeNode.Nodes.Count - 1]);
}
return nodeList;
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
I need to find the node while traversing the tree in the recursive function.
|
|
|
|
|
Isn't that recursion? GetChildNodes calling itself?
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
yes but it gives me no way to identify the last grandchild of a node .
|
|
|
|
|
I used an addressing system for a similar problem(Drawing the tree)
here your address's woud be
0.0.0
0.1.0
0.2.0
0.2.1
0.2.2
0.3.0==node1_child3 Base node
0.3.1
0.3.2
0.3.3
**Would be 1.0.0... I think the answer is then obvious.
this pattern can then be applied to any depth of child...
|
|
|
|
|
Thanks for the reply. But I still don't get the approach ? can you elaborate please . The last grandchild here is 0.3.3.
How the traversing function would be then ?
|
|
|
|
|
here is an approximation since I don't know your exact structure:
<pre>
class address
{
list<int> token;
}
list<address> addresses = Tree.MapAddress();
int generation =0;
for(int i=0;i < addresses.Count-1;i++)
{
if(addresses[i+1].token[generation] > addresses[i].token[generation])
{ Console.Writeline("Your function result Here");} }
}
</pre>
Now I had some wonky recursion like I would need to skip children(closed leaf) and step into/out of children so you can navigate (almost as fast) using the address and recursion... but it takes a LOT of code. this is the smallest patch I can think of for your situation.
also you can change the generation by swapping out the generation number so if you wanted the line between great grand children and grand children switch 0->1, and voila.
modified on Friday, October 23, 2009 2:01 PM
|
|
|
|