Click here to Skip to main content
15,867,453 members
Home / Discussions / C#
   

C#

 
Generals Text Property in a TreeNode Pin
Bill Dean22-Apr-04 3:56
Bill Dean22-Apr-04 3:56 
GeneralRe: s Text Property in a TreeNode Pin
Judah Gabriel Himango22-Apr-04 4:03
sponsorJudah Gabriel Himango22-Apr-04 4:03 
GeneralRe: s Text Property in a TreeNode Pin
Bill Dean22-Apr-04 4:10
Bill Dean22-Apr-04 4:10 
GeneralRe: s Text Property in a TreeNode Pin
Heath Stewart22-Apr-04 4:14
protectorHeath Stewart22-Apr-04 4:14 
GeneralRe: s Text Property in a TreeNode Pin
Bill Dean22-Apr-04 4:24
Bill Dean22-Apr-04 4:24 
GeneralRe: s Text Property in a TreeNode Pin
Heath Stewart22-Apr-04 4:30
protectorHeath Stewart22-Apr-04 4:30 
GeneralRe: s Text Property in a TreeNode Pin
Bill Dean22-Apr-04 4:41
Bill Dean22-Apr-04 4:41 
GeneralCircular Buffer Technique question Pin
TimTM22-Apr-04 3:45
TimTM22-Apr-04 3:45 
Hello All
I am on a project that is analogous to a game in which you are tasked to draw the number of students on campus as if you are looking from a helicopter. The students can disappear from the screen as they get into classes or buildings and more students can also added as they try to get to classes from outside campus.
I have tried to use the cirular buffering technique to buffer the total number of students at one moment and display the contents on the screen. Let's say that I have a timer that ticks every 100msec which then will try to paint the location of the student on campus.
But then the problem comes when the program tries to get the student objects from the buffer which is a collection of ArrayList's. It kept telling me that the index in the ArrayList that it's trying consume has changed. I couldn't think of how to get around it now. If you could point out what is wrong with my code, or suggest any other technique, it would be very appreciative.

Below is the code similar to mine:
public class Student
{	public string a,b,c; public int id,x,y,z;}
public class CBuffer
{  	ArrayList[] buffArrayList = {null,null,null};
	int occupiedBufferCount;

	public ArrayList BufferSet
	{
	get
	{
		lock(this)
		{
		if (occupiedBufferCount == 0)
			Monitor.Wait(this);
		ArrayList readValue = buffArrayList[readLocation];
		--occupiedBufferCount;
		readLocation = (readLocation +1)%buffArrayList.Length;
		Monitor.PulseAll(this);
		return readValue; } }
	set
	{
		lock(this)
		{
		if(occupiedBufferCount == buffers.Length)
			Monitor.Wait(this);
		buffArrayList[writeLocation] = value;
		++occupiedBufferCount;
		writeLocation = (writeLocation + 1) % buffArrayList.Length;
		Monitor.PulseAll(this); } } } 

public class Consumer
{	private ArrayList ar;
	private CBuffer buff;
	Graphics g;
	public void Consumer(CBuffer _buff, Graphics _g)
	{ 	buff = _buff; g=_g; }
	public void TestDraw()
	{
		PaintBground();
		ar = new ArrayList();
		ar = buff.BufferSet;
		foreach (Student s in ar)
			DrawStudentLocationOnScreen(); }
	private void DrawStudentLocationOnScreen(){ ..codes..}  }

public class Producer
{	private ArrayList ar;
	private CBuffer buff;
	public void Producer(CBuffer _buff)
	{  buff=_buff;}
	public void Produce()
	{
		GetStudentsFromFile();
		ar.Add(student);
		buff.BufferSet = ar; }}

GeneralRe: Circular Buffer Technique question Pin
Jeremy Kimball22-Apr-04 5:48
Jeremy Kimball22-Apr-04 5:48 
GeneralRe: Circular Buffer Technique question Pin
TimTM22-Apr-04 8:10
TimTM22-Apr-04 8:10 
GeneralRe: Circular Buffer Technique question Pin
scadaguy22-Apr-04 6:26
scadaguy22-Apr-04 6:26 
GeneralRe: Circular Buffer Technique question Pin
TimTM22-Apr-04 8:04
TimTM22-Apr-04 8:04 
GeneralRe: Circular Buffer Technique question Pin
scadaguy22-Apr-04 8:44
scadaguy22-Apr-04 8:44 
GeneralRe: Circular Buffer Technique question Pin
TimTM22-Apr-04 9:01
TimTM22-Apr-04 9:01 
GeneralWindows Forms DataGrid Pin
dcronje22-Apr-04 3:39
dcronje22-Apr-04 3:39 
GeneralRe: Windows Forms DataGrid Pin
Heath Stewart22-Apr-04 5:04
protectorHeath Stewart22-Apr-04 5:04 
GeneralRe: Windows Forms DataGrid Pin
Jeremy Kimball22-Apr-04 6:08
Jeremy Kimball22-Apr-04 6:08 
GeneralRe: Windows Forms DataGrid Pin
Heath Stewart22-Apr-04 7:24
protectorHeath Stewart22-Apr-04 7:24 
GeneralRe: Windows Forms DataGrid Pin
Jeremy Kimball22-Apr-04 7:59
Jeremy Kimball22-Apr-04 7:59 
Generalmdb Synchronize Pin
basdanny22-Apr-04 3:00
basdanny22-Apr-04 3:00 
GeneralVss 6.0c Pin
sreejith ss nair22-Apr-04 2:14
sreejith ss nair22-Apr-04 2:14 
GeneralRe: Vss 6.0c Pin
Heath Stewart22-Apr-04 2:53
protectorHeath Stewart22-Apr-04 2:53 
GeneralRemote Debugging Pin
MrEyes22-Apr-04 1:53
MrEyes22-Apr-04 1:53 
GeneralRe: Remote Debugging Pin
Heath Stewart22-Apr-04 2:55
protectorHeath Stewart22-Apr-04 2:55 
GeneralRe: Remote Debugging Pin
Tom Larsen22-Apr-04 4:41
Tom Larsen22-Apr-04 4:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.