Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Compact framerk, multithreading Invoke problem

15 views
Skip to first unread message

Piotrek "Alchemik"

unread,
Apr 27, 2005, 5:32:18 PM4/27/05
to
I found very good article:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dntake/html/yctiwy_multithreadingandui.asp
But they can use BeginInvoke and invoke with 2 parameters, but my visual studio
don't allow to do that, even it can't find BeginInvoke method. Maybe somebody
know how it should works?
Thanks a lot for any help
--
Piotrek "Alchemik" gg:183441 kilobyte[at]tlen[dot]pl
/o|o\/o|o\/o|o\/o|o\/o|o\/o|o\/o|o\/o|o\/o|o\/o|o\/o|o\/o|o\/o|o\/o|o\/o|o\/o|o\
"I am not in this world to live up to other people's expectations, nor
do I feel that the world must live up to mine." /Fritz Perls

Daniel Moth

unread,
Apr 27, 2005, 5:37:01 PM4/27/05
to
Asynchronous invocation (BeginInvoke) or passing parameters (using anything
other than EventHandler) is not supported in CF 1.0:
http://www.danielmoth.com/Blog/2004/10/invoke-cf-and-full-fx.html

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


"Piotrek "Alchemik"" <alch...@autograf.pl> wrote in message
news:d4p0d3$jts$3...@news.onet.pl...

Chris Tacke, eMVP

unread,
Apr 27, 2005, 5:36:55 PM4/27/05
to
The CF 1.0 only supports synchronous Invoke, and only with delegates that
are of the type EventHandler. That's the only option.

--
Chris Tacke
Co-founder
OpenNETCF.org
Has OpenNETCF helped you? Consider donating to support us!
http://www.opennetcf.org/donate


"Piotrek "Alchemik"" <alch...@autograf.pl> wrote in message
news:d4p0d3$jts$3...@news.onet.pl...

Piotrek "Alchemik"

unread,
Apr 27, 2005, 6:15:52 PM4/27/05
to
Daniel Moth wrote:
> Asynchronous invocation (BeginInvoke) or passing parameters (using
> anything other than EventHandler) is not supported in CF 1.0:
> http://www.danielmoth.com/Blog/2004/10/invoke-cf-and-full-fx.html

Great. I found a solutions in your blog how to pass a argument to through
invoke, but it's written in VB and i have no idea what is this:

Private Sub UpdateBox(ByVal sender As Object, ByVal e As EventArgs)
Dim o As Object SyncLock mDataQue.SyncRoot
If mDataQue.Count > 0 Then
o = mDataQue.Dequeue()
End If End SyncLock
' TODO use o
' cast o to your object/structure and
' use it to update the GUI
End Sub

Maybe somebody has a solution in C, C++, C#?

Daniel Moth

unread,
Apr 28, 2005, 5:54:02 AM4/28/05
to
Which bit do you have difficulty with?

HINT: You must learn to at least read VB.NET
HINT 2: There are many online converters (and I don't mean other people :-)


"Piotrek "Alchemik"" <alch...@autograf.pl> wrote in message

news:d4p2uq$2ab$1...@news.onet.pl...

Piotrek "Alchemik"

unread,
Apr 28, 2005, 7:49:21 AM4/28/05
to
Daniel Moth wrote:
> Which bit do you have difficulty with?
>
> HINT: You must learn to at least read VB.NET
> HINT 2: There are many online converters (and I don't mean other people :-)
>
> Cheers
> Daniel

Ok i found one, i think i'll try this later this evening.
Thank u.

Piotrek "Alchemik"

unread,
Apr 29, 2005, 3:35:56 AM4/29/05
to
Daniel Moth wrote:
I made one small project with the solution i found and it looks like:
namespace Przyklad
{
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private Thread t1;
private ThreadStart starter1;
private System.Windows.Forms.Button button1;
public Linia ln;

public Form1()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows Form Designer generated code
#endregion
static void Main()
{
Application.Run(new Form1());
}

private void button1_Click(object sender, System.EventArgs e)
{
starter1 = new ThreadStart(akcja);
t1 = new Thread(starter1);
t1.Start();
}

private void akcja()
{
ln.a="zmiana";
this.Invoke(new EventHandler(Zmiana));
Console.WriteLine(ln.a);
}

private void Zmiana (Object o, EventArgs e)
{
this.label1.Text = ln.a;
}
}


public class Linia
{
public String a;

Linia()
{
a="cos";
}
}
}

And the problem is that is not working. Maybe i'm doing something wrong?
Debugger told me that the problem is with line
this.label1.Text = ln.a;

If anybody could help me i'd be greatfull
Thanks in advance

Daniel Moth

unread,
Apr 29, 2005, 3:21:57 PM4/29/05
to
It would help if you said what the error is rather than just "there is a
problem"... anyway...

I don't see where you create the object... maybe you should change the
declaration line to:
public Linia ln = new Linia();

Also you'll have to make the constructor of Linia public:
public Linia() {


"Piotrek "Alchemik"" <alch...@autograf.pl> wrote in message

news:d4so4u$skp$2...@news.onet.pl...

Piotrek "Alchemik"

unread,
May 3, 2005, 9:09:49 AM5/3/05
to
Daniel Moth wrote:
> It would help if you said what the error is rather than just "there is a
> problem"... anyway...
>
> I don't see where you create the object... maybe you should change the
> declaration line to:
> public Linia ln = new Linia();
>
> Also you'll have to make the constructor of Linia public:
> public Linia() {

Yes, indeed in this case it works perfect, but in my more complicated example i
have the same problem wharever i create that public or not. I pass elements to
invoke function, maybe there is somethin wrong with onpaint function from the
line class?

protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
if (xLeft <= xRight)
{
Left = xLeft;
}
else
{
Left = xRight;
}
if (yLeft <= yRight)
{
Top = yLeft;
}
else
{
Top = yRight;
}
SolidBrush brush = new SolidBrush(this.Parent.BackColor);
e.Graphics.FillRectangle(brush, 0, 0, this.Width, this.Height);
Pen pen = new Pen(_color);
if (xLeft < xRight & yLeft < yRight)
{
e.Graphics.DrawLine(pen, 0, 0, this.Width, this.Height);
}
else if (xLeft > xRight & yLeft < yRight)
{
e.Graphics.DrawLine(pen, this.Width, 0, 0, this.Height);
}
else if (xLeft > xRight & yLeft > yRight)
{
e.Graphics.DrawLine(pen, this.Width, this.Height, 0, 0);
}
else if (xLeft < xRight & yLeft > yRight)
{
e.Graphics.DrawLine(pen, 0, this.Height, this.Width, 0);
}
}

And when i'm debugging my program stopped with
An unhandled exception of type 'System.ArgumentException' occurred in
System.Windows.Forms.dll

Additional information: ArgumentException when i'm trying to add my ln to
Controls. I have no other idea what else?

Message has been deleted
0 new messages