Thank you to Ilya Ryzhenkov's comment regarding my previous post about Resharper. I finally got some time to test out the code myself.
1. Indeed this is a Resharper (2.5 build 350) Bug where "Remove Parameter" didn't take consideration of delegate declaration.
For example:
1: public class Form1 : Form
2: {
3: delegate void SetTextCallback(object sender, string text);
4:
5: private void SetText(object sender, string text)
6: {
7: // InvokeRequired required compares the thread ID of the
8: // calling thread to the thread ID of the creating thread.
9: // If these threads are different, it returns true.
10: if (this.textBox1.InvokeRequired)
11: {
12: SetTextCallback d = new SetTextCallback(SetText);
13: this.Invoke(d, new object[] { this, text });
14: }
15: else
16: {
17: this.textBox1.Text = text;
18: }
19: }
20: }
However, most likely you will not encounter the runtime error that I mention. Instead, you will encounter compiling error because you would have fix your delegate declaration and therefore you would have fix the following line by removing the "this" paramter:
this.Invoke(d, new object[] { this, text });
Of course, if you missed fixing this function, then you will still run into runtime time error of InvalidCasting exception, because Invoke() try to cast "this" object to a String.
1 comment:
get more information on r4 ds and r4 dsi .
Post a Comment