---
title: "C# this.Invalidate() is blocking parent form to access"  
description: "C# this.Invalidate() is blocking parent form to access"  
author: "Anonymous User"  
published: 2013-09-24  
updated: 2013-09-24  
canonical: https://www.mindstick.com/forum/1509/c-sharp-this-invalidate-is-blocking-parent-form-to-access  
category: "c#"  
tags: ["c#", "free open source", "mindstick", "C# this.Invalidate()", "blocking parent form to access"]  
reading_time: 1 minute  

---

# C# this.Invalidate() is blocking parent form to access

I have a button on MainForm whose [button click](https://www.mindstick.com/forum/790/form-gets-submiited-twice-on-button-click) event creates a ChildForm and shows. While ChildForm is shown, i can invoke any menu [commands](https://www.mindstick.com/interview/817/what-is-the-use-of-dbcc-commands) (each menu [command](https://www.mindstick.com/blog/178/synchronous-and-asynchronous-command-execution-in-c-sharp-dot-net) is implemented to show a [message](https://www.mindstick.com/forum/12802/show-confirmation-message-yes-or-no-in-asp-dot-net) box) which are defined on MainForm without any issues.

BUT, on other hand, I kept all the code as is and override OnPaint method of ChildForm with this.Invalidate() as shown below

protected override void OnPaint(PaintEventArgs e)

{

this.Invalidate();

base.OnPaint(e);

}

Can [anyone](https://www.mindstick.com/articles/23207/how-to-find-the-best-fit-job-for-anyone) put some light on what [went wrong](https://answers.mindstick.com/qa/94671/how-do-i-create-a-google-account-when-the-page-keeps-showing-me-a-message-that-something-went-wrong) with overriding OnPaint method which executes this.Invalidate() line everytime and suggest how can I [resolve this issue](https://answers.mindstick.com/qa/95728/why-is-my-website-adsense-ads-not-matching-with-my-content-and-how-do-i-resolve-this-issue).

## Replies

### Reply by Pravesh Singh

Hi Tanuj,

You called Invalidate() which will fire OnPaint, OnPaint calls Invalidate() and again ... that's a loop of calling Invalidate() and OnPaint -> Your UI is frozen.

The solution is you have to make it more clear on what you want and your purpose of overriding OnPaint here.


---

Original Source: https://www.mindstick.com/forum/1509/c-sharp-this-invalidate-is-blocking-parent-form-to-access

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
