Page 1 of 1
Scrollpager doevents and margins of the main chart
Posted: Wed Feb 19, 2014 9:33 am
by 15654539
Please find attached this example
http://193.145.251.126/pnp/files/uOpbmT ... Scroll.zip
If you press button10 and then button1, the margin of the main chart is not correct. But if you comment the "DoEvents" instruction it runs sucessfully. Why?
Thanks
Re: Scrollpager doevents and margins of the main chart
Posted: Thu Feb 20, 2014 10:02 am
by Christopher
wakeup wrote:If you press button10 and then button1, the margin of the main chart is not correct. But if you comment the "DoEvents" instruction it runs sucessfully. Why?
I'm not sure, but according to
this MSDN article:
Caution
Calling this method causes the current thread to be suspended while all waiting window messages are processed. If a message causes an event to be triggered, then other areas of your application code may execute. This can cause your application to exhibit unexpected behaviors that are difficult to debug. If you perform operations or computations that take a long time, it is often preferable to perform those operations on a new thread. For more information about asynchronous programming, see Asynchronous Programming Model (APM).
Re: Scrollpager doevents and margins of the main chart
Posted: Thu Feb 20, 2014 10:39 am
by 15654539
Christopher wrote:wakeup wrote:If you press button10 and then button1, the margin of the main chart is not correct. But if you comment the "DoEvents" instruction it runs sucessfully. Why?
I'm not sure, but according to
this MSDN article:
Caution
Calling this method causes the current thread to be suspended while all waiting window messages are processed. If a message causes an event to be triggered, then other areas of your application code may execute. This can cause your application to exhibit unexpected behaviors that are difficult to debug. If you perform operations or computations that take a long time, it is often preferable to perform those operations on a new thread. For more information about asynchronous programming, see Asynchronous Programming Model (APM).
As you can see in the example application it doesn't do anything special with doevents.
It is only a example application to reproduce the problem I have in the real application, it is because the user adds the series, and after do other things it fills it with data. This is only a demonstration it is a error in the teechart.
In fact, you can export this chart with the problem in the margin, and if you open it again the problem is solved...
Re: Scrollpager doevents and margins of the main chart
Posted: Thu Feb 20, 2014 11:04 am
by Christopher
wakeup wrote:It is only a example application to reproduce the problem I have in the real application, it is because the user adds the series, and after do other things it fills it with data. This is only a demonstration it is a error in the teechart.
No, it is not an error in TeeChart. The MSDN caution is quite clear. Calling Application.DoEvents() causes the current thread to be suspended, which for a Graphics application which depends on a running thread to do its calculations is bound to be problematic.
If you were to call Application.DoEvents() *after* TeeChart has finished all its calculations, that is, when it has finished drawing, then this is likely to be much less problematic. As an example, the following code works without any unexpected behaviour:
Code: Select all
private void button10_Click(object sender, EventArgs e)
{
tChart1.AfterDraw += tChart1_AfterDraw;
Steema.TeeChart.Styles.Line line = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line.LinePen.Width = 2;
tChart1.Series.Add(line);
tChart1.Series[0].XValues.DateTime = true;
tChart1.Series[0].Add(new DateTime(2009, 7, 1, 0, 0, 0), 6525.4632);
tChart1.Series[0].Add(new DateTime(2009, 7, 1, 0, 30, 0), 6325.000016);
}
void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
Application.DoEvents();
}
Re: Scrollpager doevents and margins of the main chart
Posted: Thu Feb 20, 2014 11:31 am
by 15654539
Ok, forget doevents, it was only an example, it is not the main issue.
Please change my example, add a new button Button11 like this code. And press button10, then button11, and then button1... You have the same problem...
Code: Select all
private void button10_Click(object sender, EventArgs e)
{
Steema.TeeChart.Styles.Line line = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line.LinePen.Width = 2;
tChart1.Series.Add(line);
tChart1.Series[0].XValues.DateTime = true;
}
private void button11_Click(object sender, EventArgs e)
{
tChart1.Series[0].Add(new DateTime(2009, 7, 1, 0, 0, 0), 6525.4632);
tChart1.Series[0].Add(new DateTime(2009, 7, 1, 0, 30, 0), 6325.000016);
}
Re: Scrollpager doevents and margins of the main chart
Posted: Thu Feb 20, 2014 11:48 am
by Christopher
wakeup wrote:Please change my example, add a new button Button11 like this code. And press button10, then button11, and then button1... You have the same problem...
Okay, I can see the problem now. It has nothing to do with the scrollpager tool. I have added it to our bugtracker with
id=590.
Re: Scrollpager doevents and margins of the main chart
Posted: Thu Feb 20, 2014 11:59 am
by 15654539
Ok. thanks
Re: Scrollpager doevents and margins of the main chart
Posted: Thu Feb 20, 2014 3:09 pm
by Christopher
wakeup wrote:Ok. thanks
FYI: this defect has now been fixed, and I've checked with your scrollpager code that all works as expected. Using Application.DoEvents also works as in your previous example of button10_Click
Re: Scrollpager doevents and margins of the main chart
Posted: Thu Feb 20, 2014 3:41 pm
by 15654539
Nice thanks a lot!