0

I am making a program that connects to sql server and manage data on it. So, I made a form splash screen to check if the server is running and load some needed data from it like settings.

The problem is the form don’t disappear when my main form loads. I have tried:

this.Hide();

And it doesn’t work. The form stays shown and if I used

private void loading_Load( object sender , EventArgs e )
{
   // some stuff to do 
   start();
}

private void start()
{
    main form = new main( );
    form.Show( );
    this.Close( );
}

An error shows in line

static void Main( )
{
    Application.EnableVisualStyles( );
    Application.SetCompatibleTextRenderingDefault( false );
    Application.Run( new loadingfrm( ) ); // this line gets error
}

in program.cs file. It says trying to use disposed resource and the program closes completely without showing any form .

Fildor
  • 14,510
  • 4
  • 35
  • 67
oday ot
  • 11
  • 7
  • Most of the code samples you have shown us would not compile, making me dubious whether they are real code. – mjwills Oct 08 '20 at 00:21
  • Please share a [mcve]. – mjwills Oct 08 '20 at 00:21
  • sir I don't know how to but the program in minmal reproducible example format without copying my entire code and forms – oday ot Oct 08 '20 at 00:27
  • @odayot your are incorrect. create a new application, create 2 forms, and show the relevant code (that is your [mcve] in this case). There are a few reasons for your problem, none of them we can identify with what you have shown unfortunately – TheGeneral Oct 08 '20 at 00:29
  • I have made as you say and edited the post if kindly take a look at it – oday ot Oct 08 '20 at 00:40
  • @MichaelRandall I think my problem is that my splash screen is may entry point and closing it after the needed work is done ends the thread and kills my main program form because the tow of them on the same thread , however I want to pass some arguments from the splash form to the main form can it be done if the tow forms are using tow threads ? – oday ot Oct 08 '20 at 00:48

0 Answers0