?
Solved

Improving UI responsiveness of a Marquee through threading

Posted on 2010-04-05
8
Medium Priority
?
518 Views
Last Modified: 2013-11-26
I am looking to improve the responsiveness of a UI control in a .NET project.  It is a scrolling Marquee that displays RSS feeds.  I am using the NetMarquee control from an online source.  It provides a simple control to allow scrolling text.  However, the issue is that when I perform other tasks on the UI it causes the Marquee to stutter.  This is particularly true when I load images onto the UI.  I am working to reduce the workload of the image load, but that isn't really the issue.  It is just the indicator of the issue.  The issue is that the Marquee is affected by the load on the UI.  I want to isolate the Marquee if possible.

What I would like to do is operate the Marquee entirely on its own thread.  It is a self-contained component that would not need to contact the other UI components in any way.  The reverse is true as well.  So far I have found ways to marshal calls to and from worker threads, but this does not help me.  The issue is that the control itself is getting bogged down.

Is there a way to isolate one control?  I can create it at runtime, but I have heard that you cannot create a control with a parent on a different thread.  Is there a way to get around this?

As far as .NET languages go, I can do this in VB.NET or C#, so examples in either would be helpful.  I would welcome any suggestions about how to make this control operate better.  I am using Visual Studio 2008 to create these forms.  If Visual Studio 2010 would bring new features that I could leverage, I would move ahead to that platform to accomplish this task.
0
Comment
Question by:biggstrc
  • 4
  • 3
8 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 29813500
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 29825555
If it truly doesn't need any communication with the app in either direction then simply create a new application to house the control by itself.  Place it into a borderless form and then use the SetParent() API to move it into your main app making it look seamless.
0
 
LVL 1

Author Comment

by:biggstrc
ID: 29839494
CodeCruiser:
I'll look into that.  It looks interesting, but it will take a bit of work to see if it will really pay out the way I want.  Thanks for the link.  I'll let you know what I find.

Idle_Mind:
Wow, that is something I had not considered.  That seems like a simple solution that might actually work out perfectly for me.  I would still like to figure out some way to run different controls on different threads for other purposes, but this seems like the solution I need for this project.  I'll try it out and let you know how it works out.

Thanks to both of you for your help in this matter.  If you have any more bright ideas before I get back to you, please let me know.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 29839981
As a general rule of thumb: "All controls run in the SAME main UI thread".  =(

Translation: You can't run just one control in its own thread.

CodeCruisers post really describes how to put WORK into a different thread while correctly displaying progress on the main UI thread.
0
 
LVL 1

Author Comment

by:biggstrc
ID: 30169131
CodeCruiser:

The solution you posted seems to be optimized only when it comes to background processing.  The problem is that all of my processing has to be done on the foreground.  I am using GDI to move the crawl across the screen.  I can't put this type of code into a background thread.

Idle_Mind:
I think your solution is going to work.  I am working up a prototype now.  I got it to run, but I'm still working on how to get the window to resize, move, and close how I want it to.  You (or anyone else) wouldn't happen to have some example code (preferably in VB.NET but either will do) that shows how to do this would you?
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 30203849
0
 
LVL 1

Author Comment

by:biggstrc
ID: 30225901
I was able to get this to work finally.  The information from Idle_Mind really helped get me down the path.  I had to add to the solution, however, because I needed extra features (resize, close on application close, etc.) I browsed the web for a more full example.  I found this article:

http://www.codeproject.com/KB/miscctrl/AppControl.aspx

That took the SetParent() idea and made a control out of it that does just about everything I wanted it to do.  There are a couple of notes that I found were important to this setup though.  First, I wanted my sub-application (the RSS Feed) to be transparent so that it would take on the color scheme of the parent.  This works fine until you call it using the SetParent() API call.  Then it disappears entirely.  Still not sure why, but I decided not to mess with it.  I also found that it didn't like it if the sub-application didn't have a normal window around it.  There is code in the actual control that you can comment out or modify to get around this, but I decided that it was easier just to keep the normal form window since the control scrapes it off.

I appreciate all of the help.  The end result is that I have what I wanted in a working condition.  I am using a different thread for a UI component.
0
 
LVL 1

Author Closing Comment

by:biggstrc
ID: 31710999
Further explanation on the web with examples was necessary, but this solution pointed me in the right direction.  Further clarification was also added to this discussion near the end.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …
Free Data Recovery software is an advanced solution from Kernel Tools to recover data and files such as documents, emails, database, media and pictures, etc. It supports recovery from physical & logical drive after a hard disk crash, accidental/inte…
Suggested Courses

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question