473,394 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Threads & Program structure advice

Hi there,

I wanted a bit of advice on a program (a prototype) that I am trying
to write that uses threads. I will outline what I am attempting to
do, and if anyone has any advice on the way I am trying to work I
would be most grateful.

I am writing a windows forms application. This application defines a
class, lets call this myObject. I instanciate objects of this class
and store the myObjects in an ArrayList.

The main thread of this application will maintain the ArrayList of
myObjects. This could have new myObjects added, data changing for
myObjects or myObjects being removed.
I also have a groupbox on the main form. For each myObject I want to
have a PictureBox and a label to graphically rerpresent it on the
form. this will be of the order of a red picture or a green picture
depending onthe status of a myObject. I want these pictures / labels
to be updated in as close to realtime as possbile.

My current thinking for this is to use a separate thread that will be
in charge of drawing the devices to the page. So this thread would
continually cycle through the ArrayList of myObjects and either create
a PictureBox (if one doesn't already exist) or change the picture from
Red to Green if the status has changed, or do nothing if the status of
the myObject has not changed since it last redrew it.

The main reason I thought this could work would be that the worker
thread can simply draw the pictures it needs to. changing the
graphical view would be a simple process of adding / removing
myObjects to / from the ArrayList

Does this sound like a reasonable way to maintain this type of
structure?

I have been playing around with some varying levels of success so I
thought I should stop and think about this in more detail.

Am I going to hit conflict problems if my worker thread is trying to
update a picture based on a myObject and the myObject changes / gets
removed halfway through?

Can I stop and start the worker thread every time I need to make
changes to the ArrayList and restart it after, allowing it to catch
any changes?

Incidentally, my program does not affect the Status changes on a
myObject. That is something detected from outside my program and
checking the Status attribute of that myObject will cause it to give
the live Status.... so there is not really any simple way for me to
detect a change and redraw that object.

So.. I hope that all makes sense. If anyone has any advice then I
would be most grateful. I am starting to get a headache, so need to
take a step back and get high-level again.

Thanks

Mark.
Nov 22 '05 #1
0 1301

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Nick Marden | last post by:
I am trying to use threads::shared to make a thread-safe object. It appears to be the case that copying a blessed-then-shared reference to another shared variable keeps the underlying structure...
0
by: Mark Stokes | last post by:
Hi there, I wanted a bit of advice on a program (a prototype) that I am trying to write that uses threads. I will outline what I am attempting to do, and if anyone has any advice on the way I...
6
by: sathyashrayan | last post by:
Following are the selected thread from the date:30-jan-2005 to 31-jan-2005. I did not use any name because of the subject is important. You can get the original thread by typing the subject...
2
by: Suzanne | last post by:
Hi all, I'm reposting this message as I'm experiencing this problem more and more frequently : I really hope someone out there can help me as I've been tearing my hair out on this one for a...
41
by: tech guru | last post by:
Hi, I am doing some mathematical analysis on large numbers in C. The same code runs perfectly in Windows but produces unpredictable results in Unix (like negative numbers or very very big...
5
by: pt | last post by:
Hi, i am wonderng what is faster according to accessing speed to read these data structure from the disk in c/c++ including alignment handling if we access it on little endian system 32 bits...
2
by: Matthew Tylee Atkinson | last post by:
I appear to be having some problems with the isAlive() method of detecting if a thread is alive/active/running or not. I'd be grateful for any advice. I have a visualisation program (which uses...
8
by: raghu | last post by:
Hello Everyone I am working on C platform for a project in that project I need to maintain 'n' number of states where n is a dynamic value simultaneously. But I should not use any kind of...
34
by: Umesh | last post by:
I want to extract a string abc*xyz from a text file. * indicates arbitrary no. of characters. I'm only able to do it when the string has definite no. of characters or the string length is...
4
by: arnuld | last post by:
This program follows from the section 6.5 of K&R2 where authors created a doubly-linked list using a binary-tree based approach. The only thing I have rewritten myself is the getword function. I am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.