Passing reference of the main thread control

R

Ragid

Hi all,
In a previous I was offered to use Conytol.Invoke() from a thread to run
some code in the main GUI (thanks Pete for that), like in the following -

myNameSpace.myFormControl1.Invoke(myFormControl1.myDelegate);

Problem is that the code from where I want to call it is a dll which I also
pass as a reference in the IDE level(in visual studio 2005), so the
variables in the main GUI are unrecognized in the dll (to eliminate cross
reference). I thought about passing reference of the method Invoke when the
GUI calls one of the methods of the dll.
Problem is that I don't know how to pass this reference.
Can someone demonstrate on the example that I wrote above?
Regards
Ragid
 
R

ragid

Dear Mr. Pete,
I really want to paste some code from my application here but I think it
will be too complicated for you and other people to understand.
On the other hand, since my problem seems to me very common in programming,
I wander if there is somewhere an example or sample code that demonstrates
it
Can you supply such an example?
Regards
Ragid
 
R

ragid

Dear Mr. Pete,
I really want to paste some code from my application here but I think it
will be too complicated for you and other people to understand.
On the other hand, since my problem seems to me very common in programming,
I wander if there is somewhere an example or sample code that demonstrates
it
Can you supply such an example?
Regards
Ragid
 
R

ragid

Thanks,
I'm not sure that I'm doing everything completely right but my current code
works fine with Invoke() and delegates, but both threads are in the same
module and there is no problem of references. In my post I describe a new
situation where I have to invoke the method from a dll- where all my
problems begin..
I'll paste the relevant code here...
the delegate code-

(the class name is VLC)
puplic delegate void SimbuttonCaptureStream(

string client_location, string client_url, uint client_port);

public SimbuttonCaptureStream myDelegate;

public void SimbuttonCaptureStream_Click(

string client_location, string client_url, uint client_port)

{

logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name);

vlcUserControl1.PrecomputeCrop(ClientSize, 50, 100, 50, 50);

string AddAndPlay_First_Parameter = @"screen://";

...................here comes some other code

}

The code that invokes the method SimbuttonCaptureStream_Click follows

VLC.MainForm.TheMainForm.Invoke(

VLC.MainForm.TheMainForm.myDelegate, new object[] { second_paramter,
third_paramter, fifth_parameter });

Can you demonstrate in my code what should I do?

Regards

Ragid
 
R

ragid

Thanks,
I'm not sure that I'm doing everything completely right but my current code
works fine with Invoke() and delegates, but both threads are in the same
module and there is no problem of references. In my post I describe a new
situation where I have to invoke the method from a dll- where all my
problems begin..
I'll paste the relevant code here...
the delegate code-

(the class name is VLC)
puplic delegate void SimbuttonCaptureStream(

string client_location, string client_url, uint client_port);

public SimbuttonCaptureStream myDelegate;

public void SimbuttonCaptureStream_Click(

string client_location, string client_url, uint client_port)

{

logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name);

vlcUserControl1.PrecomputeCrop(ClientSize, 50, 100, 50, 50);

string AddAndPlay_First_Parameter = @"screen://";

...................here comes some other code

}

The code that invokes the method SimbuttonCaptureStream_Click follows

VLC.MainForm.TheMainForm.Invoke(

VLC.MainForm.TheMainForm.myDelegate, new object[] { second_paramter,
third_paramter, fifth_parameter });

Can you demonstrate in my code what should I do?

Regards

Ragid
 
R

Ragid

Thanks Pete,
I'm not sure that I'm doing everything completely right but my current code
works fine with Invoke() and delegates, but both threads are in the same
module and there is no problem of references. In my post I describe a new
situation where I have to invoke the method from a dll- where all my
problems begin..
I'll paste the relevant code here...
the delegate code-

(the class name is VLC)
puplic delegate void SimbuttonCaptureStream(

string client_location, string client_url, uint client_port);

public SimbuttonCaptureStream myDelegate;

public void SimbuttonCaptureStream_Click(

string client_location, string client_url, uint client_port)

{

logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name);

vlcUserControl1.PrecomputeCrop(ClientSize, 50, 100, 50, 50);

string AddAndPlay_First_Parameter = @"screen://";

...................here comes some other code

}

The code that invokes the method SimbuttonCaptureStream_Click follows

VLC.MainForm.TheMainForm.Invoke(

VLC.MainForm.TheMainForm.myDelegate, new object[] { second_paramter,
third_paramter, fifth_parameter });

Can you demonstrate in my code what should I do?

Regards

Ragid
 
R

Ragid

Thanks Pete,
I'm not sure that I'm doing everything completely right but my current code
works fine with Invoke() and delegates, but both threads are in the same
module and there is no problem of references. In my post I describe a new
situation where I have to invoke the method from a dll- where all my
problems begin..
I'll paste the relevant code here...
the delegate code-

(the class name is VLC)
puplic delegate void SimbuttonCaptureStream(

string client_location, string client_url, uint client_port);

public SimbuttonCaptureStream myDelegate;

public void SimbuttonCaptureStream_Click(

string client_location, string client_url, uint client_port)

{

logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name);

vlcUserControl1.PrecomputeCrop(ClientSize, 50, 100, 50, 50);

string AddAndPlay_First_Parameter = @"screen://";

...................here comes some other code

}

The code that invokes the method SimbuttonCaptureStream_Click follows

VLC.MainForm.TheMainForm.Invoke(

VLC.MainForm.TheMainForm.myDelegate, new object[] { second_paramter,
third_paramter, fifth_parameter });

Can you demonstrate in my code what should I do?

Regards

Ragid
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top