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 8100003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:36:22+00:00 2026-06-05T22:36:22+00:00

I started programming just few month ago so I am a pure beginner but

  • 0

I started programming just few month ago so I am a pure beginner
but I needed a math app with Heavy probability calculation and an UI to view/interact so I searched around and found C#.net was the best way… fantastic power…

It will help me a lot to progress if I am able do this :

Wpf window with textbox, in textbox a number is printed each time the calculation is done but the Ui should respond everytime

I tried to do it using latest net 4.5 because the app need to be fast (so use the most recent tech and not timer or background task)

and it work but the Ui is stuck and cannot move (because of my bad access to the text box I think)

If guys could help me it will be great and I thank you all because I learned a lot with your posts!

Here is my wrong newbie code

private Random rng;
public MainWindow()
{
    rng = new Random();
    InitializeComponent();
    Task.Run((Func<Task>) Calc);
}
private async Task Calc()
{
    while (true)
    {
        textBox1.Dispatcher.Invoke
             (DispatcherPriority.Normal
              , new Action(delegate() 
                 { 
                     textBox1.Text = rng.NextDouble().ToString(); 
                 }
                          )
              );
    }
}
  • 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-05T22:36:26+00:00Added an answer on June 5, 2026 at 10:36 pm

    You’re tightlooping, admittedly in a non-UI-thread, but adding a bazillion delegates to invoke in the UI thread… so your UI is just too busy.

    All your work is basically going on in the UI thread at the moment – you’re not even computing rng.NextDouble() in the background thread.

    Also note that you’ve got an async method without an await expression, which should have triggered a compiler warning – you should take heed of that.

    You say you don’t want to use a “background task” – but that’s exactly what you are doing by calling Task.Run.

    Now I’m assuming your real code doesn’t actually just need to create random numbers. What does your real calculation code look like, and which thread does it occur in?

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

Sidebar

Related Questions

I started learning programming a few months ago and just recently found codechef .
I have just started programming and have made a few small applications in C
I've just started programming with Java, so might appear as silly question, but I
I just started Shader programming(GLSL) and created a few with RenderMonkey. Now I want
I just started programming a week or two ago, so I apologize for the
I just started programming and tried to write something but (of course) it failed.
I've just started learning how to program a few months ago and this is
Sorry for possibly a complete noob question but I have just started programming with
I've just started programming, therefore I'm kinda noob. I'm trying to use python to
I've just started programming in Qt framework. Following is a very simple program: #include

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.