I can't believe it,this works in my other application,but in this one,which has similiar structure - it doesn't!
public string ListAdd
{
set
{
if (listView1.InvokeRequired)
{
this.Invoke((MethodInvoker)delegate
{
listView1.Items.Add(value);
});
}
else
{
listView1.Items.Add(value);
}
}
}
The way I call it:
var formz = Form.ActiveForm as Form1;
if (formz != null)
formz.ListAdd = "asdasdasdasd";
If I call it from the function where I receive packet(I want to put it on the listView) over TCP - Nothing happens,but If I call it in that same class where I initialize WinSock - it works.
Where could the problem be?
EDIT: I just debugged the application ,formz is null at the place I call it(receive function). Why is it null there,but not at any other place?