|
-
Feb 11th, 2007, 11:16 AM
#1
Thread Starter
Hyperactive Member
[3.0/LINQ] Window1 dosnt contain a definition for 'Invoke'
Here is the line of code with the Invoke in it::
VB Code:
this.Invoke(new delUpdateHistory((this.UpdateHistory)), para);
The Line Below is the Delegate for the above::
VB Code:
public delegate void delUpdateHistory(string str);
Which goes to this section of code::
VB Code:
public void UpdateHistory(string str)
{
// some code
}
this.Invoke produces this error::
Error 1 'iSCS.Window1' does not contain a definition for 'Invoke'
Invoke from what i have read is supported by .NET 3.0 Framework so the above code should work,unless i'm missing something.The code works fine in .NET 2.0 so, i'm not sure what is wrong here
So how do i go about fixing this??
-
Feb 11th, 2007, 06:01 PM
#2
Re: [3.0/LINQ] Window1 dosnt contain a definition for 'Invoke'
What type of object is iSCS.Window1? Is it a System.Windows.Forms.Form or a new .NET 3.0 type, like a System.Windows.Window? If it's the latter, does that class have an Invoke method?
-
Feb 11th, 2007, 06:17 PM
#3
Thread Starter
Hyperactive Member
Re: [3.0/LINQ] Window1 dosnt contain a definition for 'Invoke'
Its a new .NET 3.0 Type System.Windows.Window as for an Invoke Method this is what i have by Default but not sure how to write it out..
VB Code:
private void Invoke(delUpdateHistory delUpdateHistory, object[] para)
{
}
I removed "throw new Exception("The method or operation is not implemented.");"
If you want to see all the code related to the Delegate i will post it up..Thxs for the help jmcilhinney
-
Feb 11th, 2007, 06:50 PM
#4
Re: [3.0/LINQ] Window1 dosnt contain a definition for 'Invoke'
I wasn't implying that you should create your own Invoke method. Invoke is a method of the System.Windows.Forms.Control class that marshals a delegate to the thread that owns the control's handle and then invokes it. If the .NET 3.0 Window class doesn't have an Invoke method then it's for a reason. Either you don't have to worry about which thread you access WPF controls from or else there's some new mechanism to do it. My advice is to try to do what you're doing without the delegate and see what happens. If it works then I would assume that there's no issue and you don't have to care about threading issues with WPF controls. If it throws an exception then see if the IDE provides advice as to how to fix the issue. If it does then you're laughing. If it doesn't then it's time to do some research.
-
Feb 11th, 2007, 07:14 PM
#5
Thread Starter
Hyperactive Member
Re: [3.0/LINQ] Window1 dosnt contain a definition for 'Invoke'
Here are the 2 Sections of code i'm currently working with i have commented out the Delegate but need some help with getting the "UpDateHistory" to update the ListBox for each user that enters. So i need some help replacing the commented line of code so the "public void UpDateHistory(string str)" updates..
Here is the 1st block of code
Code:
//public delegate void delUpdateHistory(string str);
public void ReceiveMessage(IAsyncResult ar)
{
try
{
int bytesRead;
bytesRead = client.GetStream().EndRead(ar);
if (bytesRead < 1)
{
return;
}
else
{
string messageReceived;
int i = 0;
int start = 0;
while (data[i] != 0)
{
if (i + 1 > bytesRead)
{
break;
}
if (data[i] == 10)
{
messageReceived = partialStr + System.Text.Encoding.ASCII.GetString(data, start, i - start) + Environment.NewLine;
object[] para = { messageReceived };
//this.Invoke(new delUpdateHistory((this.UpdateHistory)), para);
Here is the Invoke i have commented out..
start = i + 1;
}
i += 1;
}
if (start != i)
{
partialStr = System.Text.Encoding.ASCII.GetString(data, start, i - start);
}
}
client.GetStream().BeginRead(data, 0, System.Convert.ToInt32(client.ReceiveBufferSize), ReceiveMessage, null);
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.ToString());
}
Here is the 2nd Block of Code Related to each other::
Code:
public void UpdateHistory(string str)
{
if (str.StartsWith("[Join]"))
{
int nameLength = str.IndexOf("]", 6);
RoomLB.Items.Add(str.Substring(7, nameLength - 7));
return;
}
else if (str.StartsWith("[Left]"))
{
int nameLength = str.IndexOf("]", 6);
try
{
RoomLB.Items.RemoveAt(RoomLB.Items.IndexOf(str.Substring(7, nameLength - 7)));
}
catch (Exception ex)
{
}
return;
}
else if (str.StartsWith("[Usrs]"))
{
string[] users = str.Substring(7, str.Length - 8).Split(',');
RoomLB.Items.Clear();
foreach (string user in users)
{
RoomLB.Items.Add(user);
}
RoomLB.Items.RemoveAt(RoomLB.Items.Count - 1);
return;
}
else if (str.StartsWith("[File]"))
{
string[] users = str.Substring(7, str.IndexOf("]", 7) - 7).Split(',');
int index = str.IndexOf("]", 7) + 2;
string filename = str.Substring(index, str.Length - index - 3);
DialogResult response;
response = System.Windows.Forms.MessageBox.Show("Do you want to download the file " + filename, "Download", MessageBoxButtons.YesNo);
if (response == System.Windows.Forms.DialogResult.Yes)
{
SendMessage("[Send_File][" + users[0] + "," + CommandTB.Text + "]");
FTP_Receive(filename);
}
return;
}
else if (str.StartsWith("[Send_File]"))
{
string userIP = str.Substring(12, str.Length - 15);
FTP_Send(fullfilename, userIP);
return;
}
else if (str.StartsWith("[Talk]"))
{
str = str.Substring(str.IndexOf("]", 7) + 1);
conStatus.AppendText(str);
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|