在Form1我已經LABEL2在設計師和我加了碼:爲什麼Form1中的label2.Text沒有從新類更新?
public void lbl2(string text)
{
label2.Text = text;
}
在新類的頂部i補充說:
private static AnimationEditor.Form1 fr1 = new AnimationEditor.Form1();
,並在新類的事件即時更新label2.Text像這樣:
int ISampleGrabberCB.BufferCB(double sampleTime, IntPtr pBuffer, int bufferLen)
{
using (var bitmap = new Bitmap(_width, _height, _width * 3, PixelFormat.Format24bppRgb, pBuffer))
{
bitmap.RotateFlip(RotateFlipType.Rotate180FlipX);
if (SaveToDisc)
{
String tempFile = _outFolder + _frameId + ".bmp";
if (File.Exists(tempFile))
{
fr1.lbl2(_frameId.ToString();
}
else
{
bitmap.Save(Path.Combine(_outFolder, _frameId + ".bmp"));
}
_frameId++;
}
else
{
if (Images == null)
Images = new List<Bitmap>();
Images.Add((Bitmap)bitmap.Clone());
}
}
return 0;
}
THEL INE在執行該更新是:
fr1.lbl2(_frameId.ToString();
現在我在新類中的這一行上使用了斷點,並且在公共函數的label2.Text中的Form1上使用了斷點,並且我看到label2文本首先是0,然後是1,然後是2等等。
但實際上在實時時,即時通訊應用程序的運行LABEL2 dosent改變其所有的時間文本SATY作爲LABEL2
這是當我點擊它,它做新的類代碼Form1的按鈕單擊事件:
private void button5_Click(object sender, EventArgs e)
{
wmv = new Polkan.DataSource.WmvAdapter(@"d:\VIDEO0040.3gp", sf);
wmv.SaveToDisc = true;
wmv.Start();
wmv.WaitUntilDone();
}
你是什麼意思UI被鎖定?沒有在Form1即時更新其他標籤,如在picturebox1鼠標移動事件我更新在一個lable1鼠標移動的座標和它的工作。我還嘗試在運行時代碼中將label2文本更改爲「hi」以進行測試,並且工作正常。所以這裏有些東西是別的東西。 – user1434011
不'fr1'需要成爲您正在使用的表單的實際參考?我看到'fr1 = new AnimationEditor.Form1();',它可能與您使用的表單不同。 – LarsTech
LarsTech AnimationEditor是命名空間。我在行label2上使用了一個斷點= text;在Form1中的lbl2函數中,並看到文本已更改。變量文本正在改變0,1,2 .... – user1434011