943,733 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Marked Solved
  • Views: 3608
  • C# RSS
You are currently viewing page 3 of this multi-page discussion thread; Jump to the first page
Dec 8th, 2008
0

Re: openin more forms C#

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.
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Dec 8th, 2008
0

Re: openin more forms C#

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!!!
Reputation Points: 10
Solved Threads: 0
Light Poster
nikola.rosic is offline Offline
27 posts
since Jul 2008
Dec 8th, 2008
1

Re: openin more forms C#

Well it most certainly wont help it.
Try setting the event on the creation of the worker, and never again
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Dec 8th, 2008
0

Re: openin more forms C#

OK i am going to do this.

thanks
Reputation Points: 10
Solved Threads: 0
Light Poster
nikola.rosic is offline Offline
27 posts
since Jul 2008
Dec 8th, 2008
0

Re: openin more forms C#

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!!!
Reputation Points: 10
Solved Threads: 0
Light Poster
nikola.rosic is offline Offline
27 posts
since Jul 2008
Dec 8th, 2008
0

Re: openin more forms C#

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.
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Dec 8th, 2008
0

Re: openin more forms C#

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.
Reputation Points: 344
Solved Threads: 116
Practically a Master Poster
Murtan is offline Offline
670 posts
since May 2008
Dec 8th, 2008
0

Re: openin more forms C#

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!!!
Reputation Points: 10
Solved Threads: 0
Light Poster
nikola.rosic is offline Offline
27 posts
since Jul 2008
Dec 8th, 2008
0

Re: openin more forms C#

ms-help://MS.VSCC.v90/MS.msdnexpress.v90.en/dv_csref/html/656da1a4-707e-4ef6-9c6e-6d13b646af42.htm
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Dec 10th, 2008
0

Re: openin more forms C#

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.
Reputation Points: 10
Solved Threads: 0
Light Poster
nikola.rosic is offline Offline
27 posts
since Jul 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Simpel string sorting
Next Thread in C# Forum Timeline: How to sort a List of FileInfo just like in a Windows folder? (Same sort Function)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC