Main Site Documentation

FEZ Cobra Redraw Speed?


#1

Hi

I am noticing that when updating the text in a textbox it takes ages to actually re-draw, by which time the message is probably redundant, see the following code:

private void btnCopyLogFiles_TouchDown(object sender, EventArgs e)
        {
            try
            {
                DateTime startDate;
                DateTime endDate;

                txtStatusText.TextContent = "Validating dates...";
                Invalidate();

                if (ValidateForm(out startDate, out endDate))
                {
                    txtStatusText.TextContent = "Valid dates, exporting now...";
                    Invalidate();

                    // Do some thing here which takes about 5-10 seconds
                    
                    // Text box only seems to show the text below, none of the previous messages are even seen
                    txtStatusText.TextContent = "Copied log files successfully";
                    
                }
            }
            catch (Exception ex)
            {
                txtStatusText.TextContent = "Exception raised: " + ex.Message;
                Invalidate();
            }
        }

The above code is from a button click, the user has entered two dates and I first validate them, and then do a task which takes about 5-10 seconds.
The issue is the text box isn’t updating before the call to the long running task, which means it looks like nothing has happened after the user selects the button.

Any help with this is appreciated
Adrian


#2

You are using WPF right?


#3

Yes


#4

And that is why :slight_smile:

GHI offers Glide as a replacement and the community has other libraries they are working on.


#5

Just tested this with the following code:

public TestWindow()
        {
            StackPanel keypadPanel = new StackPanel(Orientation.Horizontal);

            txtStartDate = new Text(Resources.GetFont(Resources.FontResources.CourierNew32Bold), "");
            txtStartDate.Height = txtStartDate.Font.Height;

            keypadPanel.Children.Add(txtStartDate);

            this.Child = keypadPanel;

            Invalidate();

            txtStartDate.TextContent = "Hello";

            Invalidate();

            txtStartDate.TextContent = "Hello again";

            Invalidate();

            txtStartDate.TextContent = "And once more";

            Invalidate();

            Thread.Sleep(10000);
        }

I only see the text box with the last line of text, nothing else can be seen, even for a split second.


#6

Yeah, I had been told that it was slow, but didn’t realise it was that slow ><. If my manager wants UI performance he’ll have to shell out for Glide. Thanks for the comments.


#7

See this very old demo http://wiki.tinyclr.com/index.php?title=GHI_Graphical_Demo
it doesn’t use glide. See how fast things run with no WPF :slight_smile:


#8

I had experienced such a problem as well. The root of the problem is when you assign a textcontent property, the control recalculates its width and send event to all other controls. This leads to the global ui layout recalculation. Especially when your ui is very complex it takes very much time to get the ui response. In my case I needed to update text about at least 5 times a second and my ui hangs up dramatically. Even updating rtc time value on ui caused freezing. Even setting manually the Width property to a fixed value didn’t work.

But fortunately the solution does exists!
I wrote my own class replacer for Text class. As a result I have one text for clock value (updating once a second) and 3 texts for numeric values (updating ten times a second). And many other ui wpf controls. I run this all on 7-inch display and I’d rather say the ui now flies)).
I’ll post this class at code.tinyclr.com asap and post a link here.


#9

Sorry for double post…
@ Admins: Please delete if possible


#10

WPF is not so bad as it seems. :wink:
Just some things need tunning :slight_smile:


#11

OK, here’s the link:

http://code.tinyclr.com/project/399/text-class-replacement/


#12

Thats great Gothic Maestro, thanks for sharing! I’ll take a look now and post back once iv tried it.


#13

Hi, Adrian2!

What are your results?