How to add code to a new thread in wpf section ?

I tried to open a new thread to ask a question but i'm not sure how to add a code with the right format ?

Example of code :

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Data;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Imaging;

using System.Windows.Navigation;

using System.Windows.Shapes;

using System.Windows.Threading;


namespace WPF_Tests

{

    /// <summary>

    /// Interaction logic for MainWindow.xaml

    /// </summary>

    public partial class MainWindow : Window

    {

        DispatcherTimer dispatcherTimer = new DispatcherTimer();


        public MainWindow()

        {

            InitializeComponent();


            CenterWindowOnScreen();


            dispatcherTimer.Tick += DispatcherTimer_Tick;

            dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 1);

            dispatcherTimer.Start();


            RichTextBoxLogger.TextChanged += RichTextBoxLogger_TextChanged;


            RichTextBoxLogger.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;

        }


        private void RichTextBoxLogger_TextChanged(object sender, TextChangedEventArgs e)

        {

            RichTextBoxLogger.ScrollToEnd();

        }


        int count = 0;

        private void DispatcherTimer_Tick(object sender, EventArgs e)

        {

            if (!StringFromRichTextBox(RichTextBoxLogger).Contains(DateTime.Now.ToString("HH:mm:ss.fff")))

            {

                RichTextBoxLogger.AppendText(DateTime.Now.ToString("HH:mm:ss"));

                RichTextBoxLogger.AppendText("\r");


                count++;


                if(count == 100)

                {

                    dispatcherTimer.Stop();

                }

            }

        }


        string StringFromRichTextBox(RichTextBox rtb)

        {

            TextRange textRange = new TextRange(

                rtb.Document.ContentStart,

                rtb.Document.ContentEnd

            );


            return textRange.Text;

        }


        private void CenterWindowOnScreen()

        {

            double screenWidth = System.Windows.SystemParameters.PrimaryScreenWidth;

            double screenHeight = System.Windows.SystemParameters.PrimaryScreenHeight;

            double windowWidth = this.Width;

            double windowHeight = this.Height;

            this.Left = (screenWidth / 2) - (windowWidth / 2);

            this.Top = (screenHeight / 2) - (windowHeight / 2);

        }

    }

}



3 Replies

UN Unknown May 5, 2022 01:58 PM UTC

Hi Daniel,


Can you please follow the steps to add a snippet while creating a new thread?

Step 01:

Paste or type your codes into RTE.


Step 02:

Select your codes in RTE, then select "Code" in the style dropdown.




Step 03:

Once you select the "code" option, click "Submit" to create a new thread. That code snippet will show up like below after it is created.



Please let us know if you still face problems posting code snippets.



Thanks,

Lalitha T.



MJ mjaks November 2, 2022 11:06 AM UTC

<p><a rel='nofollow' href="https://heylink.me/Link.Daftar.Shiowla/">SHIOWLA</a><br /><a rel='nofollow' href="https://heylink.me/Link.Daftar.Shiowla/">Link Alternatif Shiowla</a><br /><a rel='nofollow' href="https://dgcollege.ac.in/assets/kcfinder/upload/files/landing%20page%20Shiowla12.shtml">Link Daftar Shiowla</a><br /><a rel='nofollow' href="https://heylink.me/LinkDaftarRokokBet/">Rokokbet</a><br /><a rel='nofollow' href="https://heylink.me/LinkPendaftaranTogelFor4D/">For4D</a><br /><a rel='nofollow' href="https://www.situswebonline.com/p/situswebonline.html">Daftar Situs Web Judi Online</a><br /><a rel='nofollow' href="https://new.c.mi.com/ph/post/114287">Shiowla Hadiah Terbesar</a><br /><a rel='nofollow' href="https://new.c.mi.com/ph/post/114277">Shiowla Slot Gacor</a></p>



KS Kaviyapriya Suriamoorthy Syncfusion Team November 7, 2022 05:41 PM UTC

Hi Mjaks,


Are you facing the same issue? Can you please confirm whether the above mentioned steps were followed?


Regards,

Kaviyapriya



Loader.
Up arrow icon