我正在调试一个双向通信的WCF项目.我有一个回调数据,我存储在一个数组客户端,一个WinForm,并用于绘制一个控件.你可以猜到,当我读取数据时,数据从数组中写入(实际上是列表)就消失了.
对于调试,我想看看我是否正在编写和读取相同的对象,以便回调函数不会进行某种复制并将其丢弃.例如,我想看到这个指针的地址.我如何在VS2010 Exp中做到这一点?
编辑
一些代码:
现场声明:
// the cards that the player have
private List<Card> cards = new List<Card>();
Run Code Online (Sandbox Code Playgroud)
回调处理程序:
private void btnDraw_Click(object sender, EventArgs e)
{
Tuple<Card, string> update = PressedDraw(this);
cards.Add(update.Item1);
PaintCards();
}
Run Code Online (Sandbox Code Playgroud)
油漆事件:
private void cardPanel_Paint(object sender, PaintEventArgs e)
{
int counter = 0;
Point fromCorner = new Point(20,12);
int distance = 50;
foreach (Card card in cards)
{
Point pos = fromCorner;
pos.Offset(counter++ * distance, 0);
Bitmap cardBitmap =
cardFaces[Convert.ToInt32(card.suit),
Convert.ToInt32(card.rank)];
Rectangle square = new Rectangle(pos, cardBitmap.Size);
e.Graphics.DrawImage(cardBitmap, square);
}
Run Code Online (Sandbox Code Playgroud)
当我调试时,我先在回调处理程序中输入并添加一个Cardin cards
PaintCards()调用Invalidate并运行paint事件.在进入时cardPanel_Paint,cards.Count再次为零.
最好的祝福.
Görgen