openin more forms C#

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: openin more forms C#

 
0
  #21
Dec 8th, 2008
The reason I asked is every time that clicked functions called its going to add another copy of the event so you could end up with the same function called multiple times per event.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 27
Reputation: nikola.rosic is an unknown quantity at this point 
Solved Threads: 0
nikola.rosic nikola.rosic is offline Offline
Light Poster

Re: openin more forms C#

 
0
  #22
Dec 8th, 2008
Well thats true so!!!!

Is this the right way to solve this problem:

form1.MyEvent -= new MyDelegate(form1.OnEvent);

should i put this after I call clicked();

Do you think that this is the problem why my program freezes when i switch forms!!!

If the function is going to be called more times that shouldn't block the code it will only slow it down!!!
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: openin more forms C#

 
1
  #23
Dec 8th, 2008
Well it most certainly wont help it.
Try setting the event on the creation of the worker, and never again
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 27
Reputation: nikola.rosic is an unknown quantity at this point 
Solved Threads: 0
nikola.rosic nikola.rosic is offline Offline
Light Poster

Re: openin more forms C#

 
0
  #24
Dec 8th, 2008
OK i am going to do this.

thanks
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 27
Reputation: nikola.rosic is an unknown quantity at this point 
Solved Threads: 0
nikola.rosic nikola.rosic is offline Offline
Light Poster

Re: openin more forms C#

 
0
  #25
Dec 8th, 2008
Well my question is:

Should i stop the background workers when i'm switching between instances of form2.I really can't see the reason why should i do this but i'm now really out of clue why my program is behaving like this and why does it freeze when i'm switching between forms!!!
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: openin more forms C#

 
0
  #26
Dec 8th, 2008
No, because if as you say the background worker works constantly irrelevant of the form being visible or not. Then the thread shouldnt ever be started or stopped accordingly. Only on creation and termination.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 538
Reputation: Murtan is a jewel in the rough Murtan is a jewel in the rough Murtan is a jewel in the rough Murtan is a jewel in the rough 
Solved Threads: 86
Murtan Murtan is offline Offline
Posting Pro

Re: openin more forms C#

 
0
  #27
Dec 8th, 2008
In your description of MyEvent, I didn't see where any data from the background worker was transferred to the form.

Could you describe a little more about that, maybe it will have a clue.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 27
Reputation: nikola.rosic is an unknown quantity at this point 
Solved Threads: 0
nikola.rosic nikola.rosic is offline Offline
Light Poster

Re: openin more forms C#

 
0
  #28
Dec 8th, 2008
in myevent i'm comparing data and i change a color of my pictures.So this data is not shown but on the child form(instance of Form2) i have a panel and on it my drawing an graph

Graphics g = panel1.CreateGraphics();

In Myevent() i am callin an another function drawing which is drawing on panel:

drawing()
{
g.DrawLines(pen, points);
}

i am calculating points for drawing from data which i get from BGW.

and the max and average temperature which i'm collecting from BGW i'm showing also on child form:

label1.Text = max_temp;
label2.Text = average_temp;

the labels are declared in Form2 class as private:

and this is one get,set in Form2 class

public UInt16[] Alarmi_Set
{
get
{
lock (this)
{
return alarms;
}
}
set
{
lock (this)
{
alarms = value;
}
}

}


if you want i can give you all the code but there is a bunch of it and i'm trying to give you the most important stuff!!!
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: openin more forms C#

 
0
  #29
Dec 8th, 2008
ms-help://MS.VSCC.v90/MS.msdnexpress.v90.en/dv_csref/html/656da1a4-707e-4ef6-9c6e-6d13b646af42.htm
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 27
Reputation: nikola.rosic is an unknown quantity at this point 
Solved Threads: 0
nikola.rosic nikola.rosic is offline Offline
Light Poster

Re: openin more forms C#

 
0
  #30
Dec 10th, 2008
Well yesterday i tried to do something new.After i open one of the child forms and when i wish to close it I also stop the BGW which is for that child form.And then i tried to open an another child form and I could open it and the program was still running.


The only problem is that the BGW should be running all the time and not only for a while until i close it or start it again.

Well i don't have that much of experience with C# so for now this kind of experiment doesn't tell me nothing but maybe you could know where is the problem.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC