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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:06:21+00:00 2026-06-08T22:06:21+00:00

Here is my code while (true) { gg = this.CreateGraphics(); b1 = new SolidBrush(Color.Red);

  • 0

Here is my code

while (true)
{
    gg = this.CreateGraphics();
    b1 = new SolidBrush(Color.Red);
    b2 = new SolidBrush(Color.Blue);
    p1 = new Pen(Color.Red);

    neuron.transferFunction_output();
    for (int i = 0; i < 10; i++)
    {
        if (neuron.layer2[i] == 1)
        {
            gg.FillEllipse(b1, ox1 - 100 * i, oy2, (float)20, (float)20);
            for (int j = 0; j < 10; j++)
            {
                gg.DrawLine(p1, ox1 - 100 * i, oy2, ox1 - 100 * (float)j, oy3);
            }
        }
        else
        {
            gg.FillEllipse(b2, ox1 - 100 * i, oy2, (float)20, (float)20);
        }
    }
    for (int i = 0; i < 10; i++)
    {
        if (neuron.layer3[i] == 1)
        {
            gg.FillEllipse(b1, ox1 - 100 * i, oy3, (float)20, (float)20);
            for (int j = 0; j < 10; j++)
            {
                gg.DrawLine(p1, ox1 - 100 * i, oy3, ox1 - 100 * (float)j, oy4);
            }
        }
        else
        {
            gg.FillEllipse(b2, ox1 - 100 * i, oy3, (float)20, (float)20);
        }
    }
    for (int i = 0; i < 10; i++)
    {
        if (neuron.layer4[i] == 1)
        {
            gg.FillEllipse(b1, ox1 - 100 * i, oy4, (float)20, (float)20);
            for (int j = 0; j < 10; j++)
            {
                gg.DrawLine(p1, ox1 - 100 * i, oy4, ox1 - 100 * (float)j, oy5);
            }
        }
        else
        {
            gg.FillEllipse(b2, ox1 - 100 * i, oy4, (float)20, (float)20);
        }
    }
    for (int i = 0; i < 10; i++)
    {
        if (neuron.layer5[i] == 1)
        {
            gg.FillEllipse(b1, ox1 - 100 * i, oy5, (float)20, (float)20);
        }
        else
        {
            gg.FillEllipse(b2, ox1 - 100 * i, oy5, (float)20, (float)20);
        }
    }
    Thread.Sleep(1000);
    Application.DoEvents();
}//end while

Now i want to wipe the drawings made earlier in the loop.Means i dont need to show last drawing, drawn in the last iteration. If i use Graphics.clear(Color.SomeColor) then the whole background color changes after each iteration and that i dont want to do that. Secondly if declare a method that draws same lines but with white color(means a method working as an eraser) on the same track as earlier then my code gets too long and its memory taking and time taking because i have to use Thread.Sleep() in my code due to some reasons.
IS there any other way to erase the the last drawing?
Thanks in regard

  • 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-08T22:06:24+00:00Added an answer on June 8, 2026 at 10:06 pm
    while(true) {
        var g = someControl.CreateGraphics();
        draw(g);
    }
    

    That sort of construct will not work as well as one might hope. This is why you need to call DoEvents() in your loop; you’re blocking the message pump. Also, you call CreateGraphics() and paint outside of the OnPaint handler, so anything you draw will be erased when the window performs a refresh.

    You should move all of your drawing code into the OnPaint handler. This will give you a new surface to draw to every time you need it (call Invalidate() to force a re-paint) and will get you in line with the Windows message pump, so you can remove that call to (nasty) DoEvents(). You can still animate this way and your code becomes simpler.

    You can update logical interactions within your loop and call Invalidate() when you’re ready to paint the screen.

    I would suggest some reading: The Windows Message Loop.

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

Sidebar

Related Questions

Here the code on this concern: while (true) { Console.WriteLine(start + DateTime.Now); ParallelOptions options
<?php while(true){ //code goes here..... } ?> I want to make a PHP web
I keep getting this error while trying to modify some tables. Here's my code:
I have a problem using JSON and arrays. Here is my code: while($row =
Here's my code for reading my db data: OdbcDataReader rdr = cmd.ExecuteReader(); while (rdr.Read())
I here by post the code why I came across while exploring one technique.
Here is some simple code: DIR* pd = opendir(xxxx); struct dirent *cur; while (cur
Ok the error is showing up somewhere in this here code if($error==false) { $query
I have this code right here to retrive the IP-address from a hostname: program
I have a server with multiple threads. Here is my server connection: while (true)

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.