Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7905159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:22:18+00:00 2026-06-03T10:22:18+00:00

I am using Compact Framework 3.5 on a Symbol MC50. In my Sub Main

  • 0

I am using Compact Framework 3.5 on a Symbol MC50.

In my Sub Main it first checks to see if a database exists. If it does, it shows a login screen using the following code:

Dim login As frmLogin = New frmLogin()
    If login.ShowDialog() = DialogResult.OK Then            
        Application.Run(New frmMain())
    End If

This all works correctly and, when I close frmMain, it exits the application as expected.

However, if the database check in Sub Main fails, I call the ShowDialog() method of another form that is used to create and fill the database from a live server. Here is the code for calling this form:

If Not File.Exists(SETTINGS_LOCALDB) Then
        databaseExists = False
        MessageBox.Show("Local DB does not exist. The database must be created before using the application.")
        Dim update As frmUpdateData = New frmUpdateData()
        update.ShowDialog()
Else
    .....
End If

The first problem that I had is that when frmUpdateData was closed the rest of the code in Sub Main was not executing, thus the Application.Run was never being hit.

So in the click event of the Close button on frmUpdateData I added the following code:

If SystemUserSecurityId() = Nothing Then
        Dim login As frmLogin = New frmLogin()
        If login.ShowDialog() = DialogResult.OK Then
            DebugTrace("Init - login complete, starting application.")
            Application.Run(New frmMain())
        End If
    End If
    Me.Hide()

All of this code is being hit and frmMain does indeed load. However, when I click the close button in the top right nothing happens, no event occurs. Its as though the Windows events are not occurring.

What have I done wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T10:22:20+00:00Added an answer on June 3, 2026 at 10:22 am

    The reason your main form won’t close is because your application is “stuck” in the callstack of the closing event of your dialog, as that’s where you started the windows message loop for your main form.

    I would suggest your restructure your code somewhat.

    Instead of doing your validity checks in the “main” sub, load the main form instead:

    Application.Run(New frmMain())
    

    Drop a timer onto your main form and set a very quick interval (say 10 ms). Enable it in the main form’s load event. Implement the Tick event handler like so (note that my VB syntax probably isn’t perfect, I’m winging it here):

       Sub TmrOneShot_Tick(ByVal sender as Object, ByVal e as System.EventArgs)
        'prevent timer from firing again.
        tmrOneShot.Enabled = False;
        Dim bContinue as Boolean = False;
    
        If Not File.Exists(SETTINGS_LOCALDB) Then
          databaseExists = False
          MessageBox.Show("Local DB does not exist. The database must be created before using the application.")
          Dim update As frmUpdateData = New frmUpdateData()
          update.ShowDialog() ' Is this what populates your database???
    
          'analyze result of update form to determine if you should continue...
          bContinue = WasUpdateDataOperationSuccessful();
    
        End If
    
       If bContinue Then
          If SystemUserSecurityId() = Nothing Then
            Dim login As frmLogin = New frmLogin()
            bContinue = login.ShowDialog() = DialogResult.OK
            if bContinue Then
              DebugTrace("Init - login complete, starting application.")              
            End If
          End If
        End If
    
      If Not bContinue Then
         'can't continue, terminate app
         Application.Exit()
      End if
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing my first Windows CE app using the .NET Compact Framework v3.5. I
The topic says it all. Using Compact Framework C# I'm tiling (order/sequence is important)
I am developing a small app for a Motorola 9090-G using .net compact framework
I am using the .NET Compact Framework 3.5 and I am trying to determine
I'm currently learning to develop for the .net compact framework using c# in VS2008
I'm using VS2008 to create a Compact Framework application for a Windows CE 5.0
I am using SQL Server CE 3.5 and C# with the .NET Compact Framework
I am using Entity Framework 4 in a desktop application with SQL Compact. I
So I'm building an App using the Entity Framework on top of SQL Compact
Using the compact framework (ie managed code), how can I get the handle to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.