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 7859289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:51:42+00:00 2026-06-02T21:51:42+00:00

How do i load the Main form of a WPF so that a seperate

  • 0

How do i load the Main form of a WPF so that a seperate thread goes and gets data from the database while the form is in an apartmentstate ? (drag-able / movable)

I Know this is possible with opening a new window from your main form like this :

Private Sub openOrderWindow()
    Dim OrderWindow As Orders = New Orders
    OrderWindow.ShowDialog()
End Sub

Private Sub ButtonImport_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles ButtonImport.Click
    Dim iThread As System.Threading.Thread = New System.Threading.Thread(AddressOf openOrderWindow)
    iThread.SetApartmentState(System.Threading.ApartmentState.STA)
    iThread.Start()
    ListViewOrderDetail.Focus()
    ' Me.Close()
End Sub

because i use ‘ShowDialog’

But on the main window i can’t call ShowDialog

What i have Tried:

 Private Sub AccessDBFilling()
ListViewDataGrid.ItemsSource = Nothing
    accessdblist = Nothing
accessdblist = accessdb.GetFromAccess()
ListViewDataGrid.ItemsSource = accessdblist
End Sub

 Private Sub refresh()
    ListViewDataGrid.Dispatcher.Invoke(New Action(AddressOf AccessDBFilling))
End Sub

Private Sub Window_Loaded(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
    iThread = New System.Threading.Thread(AddressOf refresh)
    iThread.SetApartmentState(System.Threading.ApartmentState.STA)
    iThread.Start()
End Sub

I’ve tried putting MyBase.ShowDialog() and .Show() and .9000+ other things

The only benefit I’ve got out of using a seperate thread to load from the databse is i can see the screen right away (as oppose to it being a transparent box until it loads) but i cannot move it around or minimize it

is there any way to make it Movable while it loads?

  • 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-02T21:51:46+00:00Added an answer on June 2, 2026 at 9:51 pm

    Yes. You should understand what you did.

    ListViewDataGrid.Dispatcher.Invoke(New Action(AddressOf AccessDBFilling))
    

    The dispatcher of the UI Controls is correspond to the UI thread. so the UI is freezed, because you load data exactly on UI thread.

    Here what you should to do:

    Private Sub AccessDBFilling()
        ListViewDataGrid.ItemsSource = Nothing
        accessdblist = Nothing
        accessdblist = accessdb.GetFromAccess()
        //I'm not sure, but you can try the following lines of code. uncomment one of them.
    
        //ListViewDataGrid.Dispatcher.Invoke(() => ListViewDataGrid.ItemsSource = accessdblist);
        //ListViewDataGrid.ItemsSource = accessdblist;
    End Sub
    
    Private Sub Window_Loaded(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
        Action loadFromDb = AccessDBFilling;
        loadFromDb.BeginInvoke();
    End Sub
    

    As I’m don’t know VB, you should translate it from C# 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use the bellow code to load the main menu elements from some CMS,
I have a main page from where I am making a call to load
I am loading/unloading several swfs from one main swf. When I load a new
ViewA load some data from Coredata, then push to the next viewB . In
I have a form/subform for inputting data into an ado table. The main form's
I have created an application which inserts data into a SQL database. Basically, from
I have a windows form application that needs to load a bunch of things
I have a form that I created that is supposed to load login information
In a windows form application, on main form load, i have set a serial
I have a webpage that on a button click grays out the main form

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.