Click here to Skip to main content
15,914,447 members
Home / Discussions / C#
   

C#

 
GeneralRe: removing a table with DataSet Pin
Mr. VB.NET14-Jun-06 5:08
Mr. VB.NET14-Jun-06 5:08 
GeneralRe: removing a table with DataSet Pin
Mr. VB.NET14-Jun-06 6:39
Mr. VB.NET14-Jun-06 6:39 
GeneralRe: removing a table with DataSet Pin
Mr. VB.NET14-Jun-06 6:48
Mr. VB.NET14-Jun-06 6:48 
GeneralRe: removing a table with DataSet Pin
Mr. VB.NET14-Jun-06 11:03
Mr. VB.NET14-Jun-06 11:03 
QuestionCancel = operator on collection Pin
NaNg1524113-Jun-06 7:34
NaNg1524113-Jun-06 7:34 
AnswerRe: Cancel = operator on collection Pin
Dustin Metzgar13-Jun-06 7:44
Dustin Metzgar13-Jun-06 7:44 
GeneralRe: Cancel = operator on collection Pin
NaNg1524113-Jun-06 8:10
NaNg1524113-Jun-06 8:10 
QuestionDelegates throwing Null Exception Pin
acezrwild81713-Jun-06 7:28
acezrwild81713-Jun-06 7:28 
I am using the invoke() to call a delegate in order to communicate with another form in a different thread. The code is below.

<br />
<br />
You can see at the bottom (before the stars) where the thread is started.  The method below that is being called by the delegate in the code below the stars.  Each set of code is in a diff thread.<br />
<br />
public class MainForm : System.Windows.Forms.Form<br />
	{<br />
          private void search()<br />
          {<br />
<br />
              Search ArtifactSearch = new ArtifactSearch(this);<br />
<br />
              ArtifactSearch.SearchComplete += new Search.ProcessingCompleteDelegate(Search_ProcessingComplete);<br />
            <br />
                Thread StegSearch = new Thread(new ThreadStart(ArtifactSearch.Start));<br />
<br />
                StegSearch.Start();<br />
}<br />
<br />
private void Search_ProcessingComplete()<br />
{<br />
    //this method is being called by the delegate in the StegSearch thread above.<br />
}<br />
<br />
*********************************************************************************************<br />
<br />
        public class Search<br />
	{<br />
                MainForm Parent;<br />
<br />
	        public event ProcessingCompleteDelegate SearchComplete;<br />
		<br />
		public Search(MainForm parent)<br />
		{<br />
			Parent = parent;<br />
		}<br />
<br />
		public void Start()<br />
		{<br />
                   /// Search would take place here<br />
<br />
                   Parent.Invoke(SearchComplete,null);<br />
                }<br />
        }<br />


My problem is that when i invoke the SearchComplete delegate it tells me that "SearchComplete" is not set to an instance of an object. But as you can see it clearly is set to a new instance before the thread is started. How do I fix this. I have used delegates in this manner in other areas of my code and it worked. I'm stumped.
AnswerRe: Delegates throwing Null Exception Pin
gantww13-Jun-06 7:39
gantww13-Jun-06 7:39 
GeneralRe: Delegates throwing Null Exception Pin
acezrwild81713-Jun-06 7:58
acezrwild81713-Jun-06 7:58 
GeneralRe: Delegates throwing Null Exception Pin
gantww13-Jun-06 8:14
gantww13-Jun-06 8:14 
GeneralRe: Delegates throwing Null Exception Pin
Dustin Metzgar13-Jun-06 8:17
Dustin Metzgar13-Jun-06 8:17 
GeneralRe: Delegates throwing Null Exception Pin
acezrwild81713-Jun-06 8:27
acezrwild81713-Jun-06 8:27 
GeneralRe: Delegates throwing Null Exception Pin
gantww13-Jun-06 8:40
gantww13-Jun-06 8:40 
GeneralRe: Delegates throwing Null Exception Pin
Dustin Metzgar13-Jun-06 8:41
Dustin Metzgar13-Jun-06 8:41 
GeneralRe: Delegates throwing Null Exception Pin
gantww13-Jun-06 8:42
gantww13-Jun-06 8:42 
GeneralRe: Delegates throwing Null Exception Pin
acezrwild81713-Jun-06 9:07
acezrwild81713-Jun-06 9:07 
GeneralRe: Delegates throwing Null Exception Pin
Dustin Metzgar13-Jun-06 9:20
Dustin Metzgar13-Jun-06 9:20 
GeneralRe: Delegates throwing Null Exception Pin
acezrwild81713-Jun-06 10:09
acezrwild81713-Jun-06 10:09 
GeneralRe: Delegates throwing Null Exception Pin
Dustin Metzgar13-Jun-06 10:21
Dustin Metzgar13-Jun-06 10:21 
GeneralRe: Delegates throwing Null Exception Pin
acezrwild81713-Jun-06 14:19
acezrwild81713-Jun-06 14:19 
GeneralRe: Delegates throwing Null Exception Pin
acezrwild81713-Jun-06 14:25
acezrwild81713-Jun-06 14:25 
GeneralRe: Delegates throwing Null Exception Pin
gantww14-Jun-06 3:17
gantww14-Jun-06 3:17 
GeneralRe: Delegates throwing Null Exception Pin
acezrwild81714-Jun-06 8:14
acezrwild81714-Jun-06 8:14 
GeneralRe: Delegates throwing Null Exception Pin
acezrwild81713-Jun-06 8:53
acezrwild81713-Jun-06 8:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.