Click here to Skip to main content
15,887,267 members
Home / Discussions / C#
   

C#

 
GeneralRe: Setup & deployment Project - Desktop shortcut - unable to edit target property Pin
Heath Stewart22-Apr-04 7:31
protectorHeath Stewart22-Apr-04 7:31 
GeneralRe: Setup & Deployment project - "All User" installation Pin
Heath Stewart22-Apr-04 4:57
protectorHeath Stewart22-Apr-04 4:57 
GeneralRe: Setup & Deployment project - "All User" installation Pin
Ruchi Gupta22-Apr-04 5:20
Ruchi Gupta22-Apr-04 5:20 
GeneralMulti images in each row in a listbox Pin
thomasa22-Apr-04 4:38
thomasa22-Apr-04 4:38 
GeneralRe: Multi images in each row in a listbox Pin
patnsnaudy22-Apr-04 4:52
patnsnaudy22-Apr-04 4:52 
GeneralInserting html code on a textbox control Pin
devgeez22-Apr-04 4:36
devgeez22-Apr-04 4:36 
GeneralRe: Inserting html code on a textbox control Pin
devgeez22-Apr-04 5:05
devgeez22-Apr-04 5:05 
GeneralRe: Inserting html code on a textbox control Pin
Heath Stewart22-Apr-04 5:09
protectorHeath Stewart22-Apr-04 5:09 
GeneralRe: Inserting html code on a textbox control Pin
Heath Stewart22-Apr-04 5:09
protectorHeath Stewart22-Apr-04 5:09 
GeneralLoading in old MFC Serialized files Pin
Simon Wren22-Apr-04 4:07
professionalSimon Wren22-Apr-04 4:07 
GeneralRe: Loading in old MFC Serialized files Pin
Heath Stewart22-Apr-04 4:10
protectorHeath Stewart22-Apr-04 4:10 
GeneralRe: Loading in old MFC Serialized files Pin
Simon Wren22-Apr-04 4:18
professionalSimon Wren22-Apr-04 4:18 
GeneralRe: Loading in old MFC Serialized files Pin
Heath Stewart22-Apr-04 4:28
protectorHeath Stewart22-Apr-04 4:28 
GeneralRe: Loading in old MFC Serialized files Pin
Simon Wren22-Apr-04 4:38
professionalSimon Wren22-Apr-04 4:38 
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 

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.