Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8515853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:15:37+00:00 2026-06-11T05:15:37+00:00

I am trying to find/develop a very lightweight method to display text in a

  • 0

I am trying to find/develop a very lightweight method to display text in a pane for my desktop application. Other than setting a single font for all text, I have no requirements for text formatting. I have tried using a TextBox, TextBlock, and various observable collections. Computational efficiency is paramount.

The text is created by the application, and is never modified by the user. The overriding requirement is that the application typically generates text at from 100 to 700 lines per second with a peak rate of 1900 lines per second. It is not unusual for the application to run for several days. Ideally, the display would scroll continuously so that the last line added was always visible.

My current implementation uses a TextBox (For longer periods, I currently have no choice but to disable text display). Things I have tried include:

  • setting IsUndoEnabled=”False”
  • removing the first line of text for every line of text added after n (usually 1000). This was really ugly and prompted me to try redesigning it as MVVM.
  • using an Observable Collection or a BindingList with a ListView (ala
    MVVM) (Suprisingly this was worse than the TextBox even with the following)
  • suppressing collection/list changed so that UI updates were deferred
    to ‘idle’ periods.

I can provide more details on what I have tried, but I didn’t want to start by writing a book.

This is my current XAML implementation:

<TextBox Grid.Row="1" Name="tbTraceLog" IsReadOnly="True" IsUndoEnabled="False" VerticalScrollBarVisibility="Auto" FontFamily="Courier New"/>

And in codebehind:

    for (icount = 0; icount < tlData.stringcount; icount++)
    {
        tbTraceLog.AppendText(tlData.s[icount]);          // TextBox implementation
        if (tbTraceLog.LineCount > 1000)
        {
            // Remove one line
            tbTraceLog.Text = tbTraceLog.Text.Substring(tbTraceLog.Text.IndexOf('\n')+1);
        }
    }
    tbTraceLog.ScrollToEnd();

Is there a more basic text rendering class where I can start? What classes does TextBlock/TextBox inherit from?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T05:15:39+00:00Added an answer on June 11, 2026 at 5:15 am

    I don’t believe the control selection is the issue, I believe your issue is the performance related to maintaining string concatenation. I’m assuming that since you attempted to remove the first entry to add a new one after 1000 that you do not need to keep a history. Nor handling the max 1900 messages generated per 1 second is a requirement.

    I would keep the TextBox as your control. Make it multi-line and readonly.

    Create a class level List for your results:

    List<string> list = new List<string>();
    

    Create a public string Property:

    public string Result 
    { 
        get 
        { 
            return string.Concat(list); 
        } 
    }
    

    In your XAML, bind the TextBox.Text to the Result property:

    <TextBox Text="{Binding Path=Result}" />
    

    Next create a class level boolean called update:

    private bool update = false;
    

    When you receive the result to concatenate, check if list.Count > 1000. If it is, list.RemoveAt(0) and then list.Add(newTextToAdd + Environment.NewLine). Then set update to true. Please note I’m assuming you receive the text to add one at a time. If you have a collection of text received, you can calculate the how many to remove, then call list.AddRange(collection).

    if (list.Count > 1000)
    {
        list.RemoveAt(0);
        list.Add(newTextToAdd + Environment.NewLine);
    }    
    update = true;
    

    Create a timer. I would say set it to fire 1 second. Then, when it fires check if we updated our List. If so raise the Result property changed notification and then set update to false:

    if (update)
    {
        OnPropertyChanged("Result");
        update = false;
    }
    

    That should do it. I think the string.Concat should be fast enough to handle your load if you have it on the 1 second timer. I think using the timer is acceptable because the application generates X amount of messages per second. Queueing into the List should also be okay because you’re only going to miss seeing text if it generates more than 1000 in a second. Since you already attempted to limit the max to 1000, supporting more doesn’t appear to be a requirement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to find out if it's possible to develop a key capturing application
I am trying to develop an Android application that can be used to find
Trying to find a good name for a method swapping each coordinate X and
I am trying very hard to develop a much deeper understanding of programming as
I am trying to develop an application to search through the receive calls in
I am trying to develop a sample application that finds the process name of
i am trying to develop a very simple program for classifying and categorising documents
I am trying to learn something basic and very important to develop decent iPhone
Trying to find a way to rapidly develop web services on the Mac Server
I'm trying to develop a genetic algorithm that will find the most efficient way

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.