---
title: "UI Threading Helper Classes"
url: "https://osherove.com/blog/2003/5/17/ui-threading-helper-classes-1.md"
canonical: "https://osherove.com/blog/2003/5/17/ui-threading-helper-classes-1.html"
published: "2003-05-17T21:53:00"
updated: "2003-05-17T21:53:00"
tags: [".Net Original"]
author: "Roy Osherove"
description: "Following up on my post about how UI threading sucks , and Julie's post about the subject (Julie or Julia? which is it?), I've decided to create some helper classes for working with UI threads. Meet UIThreadHandler and…"
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# UI Threading Helper Classes

By Roy Osherove May 17, 2003 In [.Net Original](https://osherove.com/blog/category/net-original)

**Historical article** · Originally published May 17, 2003; technical details may be outdated.

Following up on my post about how [UI threading sucks](http://dotnetweblogs.com/rosherove/posts/6554.aspx) , and [Julie's post](http://dotnetweblogs.com/jlerman/posts/6562.aspx) about the subject (Julie or Julia? which is it?), I've decided to create some helper classes for working with UI threads. Meet **UIThreadHandler** and **UIThreadManager**.

Basically, they save you a lot of time by saving you the trouble of creating method stubs which call Invoke() on the form (which is what you need to do when getting events from a separate thread).

You can read all about them and how to use them - [here](http://dotnetweblogs.com/rosherove/story/7171.aspx), or you can just [download the code](http://www.codeproject.com/useritems/VSNetRegHelper/UIManager.zip) and look.

**but here's a taste**: This is all I need to do to call events from a separate thread - no need to create a method stub   - just creating a new **UIThreadHandler** does the job:

EventThrower e = new EventThrower();

UIThreadHandler h = UIManager.CreateHandler(this,new EventHandler(this.UpdateProgressBar));

e.OnEventThrow+=new MyHandler(h.BaseEventHandler);

e.Start();

I think these classes could be expended much further, but for now they save me a bunch of time already. Have fun :)

## More in .Net Original

[All posts in .Net Original](https://osherove.com/blog/category/net-original)

- May 19, 2003

    ### [Ingo Rocks Too](https://osherove.com/blog/2003/5/19/ingo-rocks-too.html)

- May 19, 2003

    ### [Articles, Articles, Articles!](https://osherove.com/blog/2003/5/19/articles-articles-articles.html)

- May 15, 2003

    ### [System.Text.Encoding.Tip](https://osherove.com/blog/2003/5/15/systemtextencodingtip.html)

- May 14, 2003

    ### [A Long Day!](https://osherove.com/blog/2003/5/14/a-long-day.html)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
