Compact framework threads and forms problem

  • Thread starter Thread starter Piotrek \Alchemik\
  • Start date Start date
P

Piotrek \Alchemik\

I have small problem with my project for Windows Ce, i'm using some threads and
i'd like them to paint something on my form. The problem is, that only way i can
do that is using invoke, unfortunetly in compact framework there is no way how
to pass parameters through invoke. I was trying to create a small class
with a public method (the delegate), and a few public properties (the
parameters).

-Instantiate the class
-set the properties
-Call Form.Invoke and pass it a reference to the class' public method

when the delegate gets called, your code can then reference the
properties you set but it didn't work as well. Maybe there is a way to do that
in different way?
Thanks a lot :-)
 
Have a look through the archives to see if anything helps.
http://groups-beta.google.com/group...soft.public.dotnet.framework.compactframework

If not, try posting this question to the official CF newsgroup.
microsoft.public.dotnet.framework.compactframework

--
Tim Wilson
..Net Compact Framework MVP

Piotrek "Alchemik" said:
I have small problem with my project for Windows Ce, i'm using some threads and
i'd like them to paint something on my form. The problem is, that only way i can
do that is using invoke, unfortunetly in compact framework there is no way how
to pass parameters through invoke. I was trying to create a small class
with a public method (the delegate), and a few public properties (the
parameters).

-Instantiate the class
-set the properties
-Call Form.Invoke and pass it a reference to the class' public method

when the delegate gets called, your code can then reference the
properties you set but it didn't work as well. Maybe there is a way to do that
in different way?
Thanks a lot :-)
/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[/QUOTE]
 
Tim said:
Have a look through the archives to see if anything helps.
http://groups-beta.google.com/group...soft.public.dotnet.framework.compactframework

If not, try posting this question to the official CF newsgroup.
microsoft.public.dotnet.framework.compactframework

I was already trying to find an answer there. I was looking for answer here, i
don't even why. I tried all the combinations, i made for example small project
only with this and i get the same problem as above. Maybe i should add some code:

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";
}
}
}

Maybe i got something with my system and this code works on others?
Thanks a lot
 
I would suggest posting this question in the official CF newsgroup.
microsoft.public.dotnet.framework.compactframework

--
Tim Wilson
..Net Compact Framework MVP

Piotrek "Alchemik" said:
I was already trying to find an answer there. I was looking for answer here, i
don't even why. I tried all the combinations, i made for example small project
only with this and i get the same problem as above. Maybe i should add some code:

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";
}
}
}

Maybe i got something with my system and this code works on others?
Thanks a lot
/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[/QUOTE]
 
Back
Top