Problem with emulator

D

David

Hi,

I am using the 'standalone' emulator with WM 5, so that I can connect to
activesynch.

I have a project (C# .NET CF 1) that works perfectly on my WM6 real device
and a colleagues real WM5 device. However, it is crashing on the emulator...

My code is...

Thread splashThread = new Thread(new ThreadStart(StartSplash));
splashThread.Start();

// Pretend that our application is doing a bunch of loading and
// initialization
Thread.Sleep(kMinAmountOfSplashTime_ms / 4);


// Sit and spin while we wait for the minimum timer interval if
// the interval has not already passed
while (sForm.GetUpMilliseconds() < kMinAmountOfSplashTime_ms)
{
Thread.Sleep(kSplashUpdateInterval_ms / 4);
}


What happens is that I get an error that I see, but is then masked by the
splashscreen, but the splash never disappears. At the moment, I have
remarked this code so that I can get it to work, but I would really like it
to work on the emulator.

Alternatively, if this code will never work on the emulator, is there anyway
that I can check if the current device is real or emulated? I could perhaps
skip the splash code...

Any help would be appreciated.


Further code...

static public void StartSplash()
{
// Instance a splash form given the image names
//splash = new SplashForm(kSplashUpdateInterval_ms);
sForm = new splash(kSplashUpdateInterval_ms);

// Run the form
Application.Run(sForm);
}


My splashform has...


int numUpdates = 0;
int timerInterval_ms = 0;

System.Threading.Timer splashTimer = null;

public int GetUpMilliseconds()
{
return numUpdates * timerInterval_ms;
}

protected void Draw(Object state)
{
numUpdates++;
}

public void KillMe(object o, EventArgs e)
{
this.Close();
}

public splash(int timerInterval)
{

timerInterval_ms = timerInterval;

this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
this.BackColor = Color.White;

InitializeComponent();

}


protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}


private void splash_Load(object sender, System.EventArgs e)
{
// Make the form full screen
this.Text = "";
this.MaximizeBox = false;
this.MinimizeBox = false;
this.ControlBox = false;
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
this.Menu = null;

// Start a timer that will call Draw every 200 ms
System.Threading.TimerCallback splashDelegate = new
System.Threading.TimerCallback(this.Draw);
this.splashTimer = new System.Threading.Timer(splashDelegate, null,
timerInterval_ms, timerInterval_ms);

}


--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
S

Simon Hart [MVP]

What error are you getting? Does the emulator has the lastest and same
service pack as the real devices installed?

The only way really to detect if you are running on an emulator is by
checking the deviceid or the IMEI code (if phone edition (professional)
device) will return a bunch of zeros.
 
D

David

I can't see the error as the splashscreen comes up over the top and just
sits there.

I am guessing it is to do with the threading, as the thread is supposed to
close the splash down, but that never happens. Without the splash, I don't
get an error, so it has to be within the splash screen.

As I am coming from visual studio 2003, I can't connect to the emulator
(unless you know how to) to debug step.

The target device for my app is just a regular windows mobile device, not
neccessarily a phone, so IMEI could be a problem. (The work around is only
so that I can get it working on the emulator).

My device is WM6. The other is WM5, but that is all I know.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
C

Chris Tacke, eMVP

Have you considered trying to put a try/catch around the code to capture
whatever is being thrown? It might help you identify what it is, and
subsequently a fix.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com
 
D

David

Hi,

I have tried putting try/catch around, but this doesn't really make a
difference.

In my startsplash function, I have remarked the Application.Run and now have
the error visible.

App.exe
NullReferenceException

Form1::Form1_Load+0x2b
Form::OnLoad_0x15
Form::_SetVisibleNotify+0x1d
Control::set_Visible+0x1f
Application::Run+0x7
Form1::Main+0xa


My startsplash function is...

static public void StartSplash()
{
sForm = new splash(kSplashUpdateInterval_ms);

Application.Run(sForm);
}


I have put a try catch around the sForm. Didn't fall into the catch/

I put a messagebox before sForm and that got hit.

I put a messagebox into the splash function and that got hit, but whilst it
was there, I got the error (NullReferenceException) as defined above.


Now, I have not done much threading, my splash form is in a thread.

So that I don't have to keep the splash in memory, at the top of my form1, I
have...

const int kSplashUpdateInterval_ms = 200;

const int kMinAmountOfSplashTime_ms = 5000;

static splash sForm = null;


As I say, it only happens on this version of the emulator. It worked happily
on versions that I was using with studio 2003.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
C

Chris Tacke, eMVP

Without knowing a lot more, I'd say you've got some sort of a bug in your
code that has to do with the creation of some control. You say you have you
spalsh screen ina Thread, but I see no threads, and the statement alone
makes no sense to me. You're saying you're calling Application.Run twice in
your app? If so, I could see that leading to no good.

If it worked in CF 1.0 but fails in 2.0, that's not a surprise eitehr. CF
1.0 allowed a few bad practices without excepting that 2.0 plugged.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com
 
S

Simon Hart [MVP]

When do you call the method KillMe() method on the Splash class. You should
call this in the Activated event for the main form ideally. Also change the
following code:

static public void StartSplash()
{
// Instance a splash form given the image names
//splash = new SplashForm(kSplashUpdateInterval_ms);
sForm = new splash(kSplashUpdateInterval_ms);

// Run the form
Application.Run(sForm);
}

To

static public void StartSplash()
{
// Instance a splash form given the image names
//splash = new SplashForm(kSplashUpdateInterval_ms);
sForm = new splash(kSplashUpdateInterval_ms);

// Run the form
sForm.ShowDialog();
}

Don't have 2 Application.Run calls - although in your case you are setting
up two message pumps (main UI threads) will work - it's overkill and uses
more memory/CPU than required.

My bet is you're killing the form before it's had time to load.
 
D

David

This didn't work (sForm.showDialog()) on my real device. I get a
NotSupportedException and that the error message cannot be displayed because
an optional resource assembly containing it cannot be found. (I guess it is
something to do with the dispose as the form is no longer being run by
Application.Run).

Not sure where to put the KillMe stuff you talk about.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
D

David

In my original message, I have...


StartSplash is a local method that actually launches the splashscreen...



I am developing in CF 1, this runs perfectly fine on both a WM5 and WM6
device (real devices), yet on the emulator, (WM 5), it doesn't work.

(

The emulator device version details are:

Micorsoft Windows Mobile Version 5.0
OS 5.1.195 (Build 14847.2.0.0)

Processor : ARM920T DeviceEmulator

)

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 

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