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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:13:47+00:00 2026-05-22T02:13:47+00:00

I am trying to display an image via powershell. I made a script based

  • 0

I am trying to display an image via powershell. I made a script based on this forum post.

If I use ShowDialog() it works fine, except the powershell execution stops while the dialog is up. However, that is by design for a modal dialog. If I call Form.Show() in PowershellISE the form shows up, but freezes and cannot be moved or dismissed. Behavior is similar if I copy and past the code to a powershell console.

How do I make the dialog non-modal, and not freeze.

  • 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-05-22T02:13:48+00:00Added an answer on May 22, 2026 at 2:13 am

    First Answer Why it appends.

    In a Windows graphic program the thread which create a Window must loop in a message pump in order to redistribute (translate) messages coming from the user action to events in his Windows.

    In a modal window, the modal code that handles the window display runs its own message pump loop and doesn’t return until the window is closed. That’s why the code after ShowDialog() won’t execute until the window is closed.

    Show(), just ask to show the Window, but if there is no pump loop to manage the messages coming from user action, it just freezes.

    Second a simple way to have two threads

    The CmdLet start-job use another thread from the pool allocated by Powershell so it makes the dialog non-modal, and it does not freeze.

    function goForm
    {
      [void][reflection.assembly]::LoadWithPartialName("System.Windows.Forms")
    
      $file = (get-item 'C:\temp\jpb.png')
      #$file = (get-item "c:\image.jpg")
    
      $img = [System.Drawing.Image]::Fromfile($file);
    
      # This tip from http://stackoverflow.com/questions/3358372/windows-forms-look-different-in-powershell-and-powershell-ise-why/3359274#3359274
      [System.Windows.Forms.Application]::EnableVisualStyles();
      $form = new-object Windows.Forms.Form
      $form.Text = "Image Viewer"
      $form.Width = $img.Size.Width;
      $form.Height =  $img.Size.Height;
      $pictureBox = new-object Windows.Forms.PictureBox
      $pictureBox.Width =  $img.Size.Width;
      $pictureBox.Height =  $img.Size.Height;
    
      $pictureBox.Image = $img;
      $form.controls.add($pictureBox)
      $form.Add_Shown( { $form.Activate() } )
      $form.ShowDialog()
    }
    
    Clear-Host
    
    start-job $function:goForm
    
    $name = Read-Host "What is you name"
    Write-Host "your name is $name"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to display an image inside a ListView control based on the value
I'm trying to display an update progress loading image whenever my update panel does
I'm trying to animate an image which is partly hidden (via overflow: hidden) inside
im trying to display image when left mouse button is down. i can display
I have been trying to display image from database using php but i am
I am trying to display an image from a URL, which may be larger
I'm trying to display an image (.gif) for page loading in html page until
It's me your junior programmer extraodinaire I'm trying to display an image from my
i am trying to display image from internet in my imageview. which is raising
I'm trying to display an image that I load from a pixbuf( from data

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.