Click here to Skip to main content
15,891,943 members
Home / Discussions / C#
   

C#

 
GeneralRe: Need assistance with a Producer/Consumer Queue logic where the Consumer can create a limited number of worker threads Pin
harold aptroot24-Apr-09 13:38
harold aptroot24-Apr-09 13:38 
AnswerRe: Need assistance with a Producer/Consumer Queue logic where the Consumer can create a limited number of worker threads Pin
Giorgi Dalakishvili24-Apr-09 22:59
mentorGiorgi Dalakishvili24-Apr-09 22:59 
Questionbluetooth stacks Pin
akinwaadeolu24-Apr-09 12:06
akinwaadeolu24-Apr-09 12:06 
QuestionWCF Question Pin
NETLearning24-Apr-09 11:58
NETLearning24-Apr-09 11:58 
AnswerRe: WCF Question Pin
Hesham Amin24-Apr-09 12:33
Hesham Amin24-Apr-09 12:33 
GeneralWCF Question Pin
NETLearning25-Apr-09 6:13
NETLearning25-Apr-09 6:13 
GeneralRe: WCF Question Pin
Hesham Amin25-Apr-09 23:04
Hesham Amin25-Apr-09 23:04 
QuestionFormatting data in a datagridview Pin
bwood202024-Apr-09 9:23
bwood202024-Apr-09 9:23 
QuestionMulti Column display ina listbox Pin
edlanka24-Apr-09 9:07
edlanka24-Apr-09 9:07 
AnswerRe: Multi Column display ina listbox Pin
DaveyM6924-Apr-09 9:09
professionalDaveyM6924-Apr-09 9:09 
GeneralRe: Multi Column display ina listbox Pin
edlanka24-Apr-09 9:39
edlanka24-Apr-09 9:39 
GeneralRe: Multi Column display ina listbox Pin
Dan Neely24-Apr-09 9:49
Dan Neely24-Apr-09 9:49 
QuestionClosing DialogBox from other application Pin
Papi83dm24-Apr-09 7:47
Papi83dm24-Apr-09 7:47 
QuestionRemoving bytes from an exe file..... is it possible? Pin
Rajdeep.NET is BACK24-Apr-09 6:15
Rajdeep.NET is BACK24-Apr-09 6:15 
AnswerRe: Removing bytes from an exe file..... is it possible? Pin
musefan24-Apr-09 6:36
musefan24-Apr-09 6:36 
GeneralRe: Removing bytes from an exe file..... is it possible? Pin
Rolando CC24-Apr-09 7:40
professionalRolando CC24-Apr-09 7:40 
AnswerRe: Removing bytes from an exe file..... is it possible? Pin
Ben Fair24-Apr-09 8:38
Ben Fair24-Apr-09 8:38 
AnswerRe: Removing bytes from an exe file..... is it possible? Pin
Skymir24-Apr-09 10:16
Skymir24-Apr-09 10:16 
AnswerRe: Removing bytes from an exe file..... is it possible? Pin
OriginalGriff24-Apr-09 23:23
mveOriginalGriff24-Apr-09 23:23 
QuestionWeird Collection Thing [modified] Pin
#realJSOP24-Apr-09 5:55
mve#realJSOP24-Apr-09 5:55 
I have the following collection:

public class PopupWindowItem
{
	public Object WindowObject { get; set; } // wpf window object
	public UDPWindowType WindowType { get; set; } // wpf tabitem object
	public bool AllowMultipleInstances { get; set; }

	public PopupWindowItem(Object window, UDPWindowType windowType, bool allowMultiple)
	{
		this.WindowObject           = window;
		this.WindowType             = windowType;
		this.AllowMultipleInstances = allowMultiple;
	}
}

public class PopupWindowManager : List<PopupWindowItem>
{
	public PopupWindowManager()
	{
		this.Clear();
	}
}


When the user clicks a button to open a window, a new PopupWindowItem is created and populated with the indicated objects. This part woerks fine. Here's the code:

WindowAccountManager accountManager = new WindowAccountManager();
accountManager.Closed += new EventHandler(accountManager_Closed);
m_popupWindowMgr.Add(new PopupWindowItem(accountManager, UDPWindowType.AccountManager, false));
accountManager.Show();


When the application is closed, I traverse the PopupWindowManager collection and close the windows indicated therein. This is where it gets interesting. Here's the code I'm using:

while (m_popupWindowMgr.Count > 0)
{
	switch (m_popupWindowMgr[0].WindowType)
	{
		case UDPWindowType.AccountManager :
			{
				// When you close the Window object inside the PopupWindowItem object, 
				// the PopupWindowItem object is removed from the collection, and the 
				// collection's count is reduced by 1.
				((WindowAccountManager)(m_popupWindowMgr[0].WindowObject)).Close();
			}
			break;
	}
}


When I call close on the window object inside the PopupWindowItem object, the whole PopupWindowObject is removed from the collection. As you might guess this is unexpected behavior. Why is it doing this?


"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001


modified on Friday, April 24, 2009 12:15 PM

AnswerRe: Weird Collection Thing Pin
Gideon Engelberth24-Apr-09 7:21
Gideon Engelberth24-Apr-09 7:21 
GeneralRe: Weird Collection Thing Pin
Rolando CC24-Apr-09 7:43
professionalRolando CC24-Apr-09 7:43 
GeneralRe: Weird Collection Thing Pin
#realJSOP24-Apr-09 8:15
mve#realJSOP24-Apr-09 8:15 
Questionwatch video live stream on pda (broadcast from pc) Pin
b_emsi24-Apr-09 5:50
b_emsi24-Apr-09 5:50 
Questiondatasets over class objects to store data Pin
Tina P24-Apr-09 5:35
Tina P24-Apr-09 5:35 

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.