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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:51:38+00:00 2026-05-22T12:51:38+00:00

I have only been working with C# for a few weeks and I have

  • 0

I have only been working with C# for a few weeks and I have gotten stuck on a threading issue.

I’ve been building a custom slideshow that implements a .ppt presentation hosted in a winform handled by an independent class. The slideshow switches off with another program that displays dynamic data from a shop floor. This second program needs to be sent a command to enter full screen mode as I do not have access to it’s source code.

Using Setforegroundwindow API I can easily switch between the two applications and control the power point with the COM interface but the transition is choppy with screens resizing. I would like to overlay a blank black winform that fades in and out while this transition occurs. So far I have been unsuccessful in doing this smoothly, I have tried running the fading form and transition on separate threads but I haven’t got it quite figured out. If anyone might have any advice on how to do this it would be much appreciated.

Thank you.

  • 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-22T12:51:39+00:00Added an answer on May 22, 2026 at 12:51 pm

    After working through some example code I implemented a background worker that did the trick. For more info From msdn – How to: Use a Background Worker.

    I’m trying to find a more reliable way to ensure the F11 command is processed by the application, but for now I’ve put in a Thread.Sleep before the SendKeys.

    Please feel free to leave comments or questions.

    [DllImport("user32.dll")]
        [return: MarshalAs(UnmanagedType.Bool)]
        static extern bool SetForegroundWindow(IntPtr hWnd);
    
        Process p;
        //Process p is initialized: p = Process.Start(@"<path\application.exe>");
        Form2 oForm;
    
     private void transition()
        {
            BackgroundWorker bw = new BackgroundWorker();
            oForm = new Form2();
    
            bw.DoWork += new DoWorkEventHandler(bw_DoWork);
            bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);
            oForm.Show();
            if (bw.IsBusy != true)
            {
                bw.RunWorkerAsync();
            }
    
        }
        private void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {       
            oForm.closethis();
        }
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;
    
                if ((worker.CancellationPending == true))
                {
                    e.Cancel = true;                   
                }
                else
                {                   
                    SetForegroundWindow(p.MainWindowHandle);
                    p.WaitForInputIdle(3000);
                    System.Threading.Thread.Sleep(500);
                    SendKeys.SendWait("{F11}");    
                    //Sends the application into full screen mode           
                }
    
        }
    

    And the code for the form that fades in and out..

    public partial class Form2 : Form
    {
        public Form2()
        {
            this.Visible = false;
            this.Opacity = 0;
    
            InitializeComponent();
    
            this.TopMost = true; 
            this.Visible = true;
    
            while (this.Opacity < 1)
            {
               this.Opacity += .05;
               Thread.Sleep(5);
               this.TopMost = true;
            }       
        }
        private void closefade()
        {
            while (this.Opacity > 0)
            {
                this.Opacity -= .05;
                Thread.Sleep(5);
                this.TopMost = true;
            }
            this.Close();
        }
    
        delegate void CloseBack();
        public void closethis()
        {
            if (this.InvokeRequired)
            {
                CloseBack b = new CloseBack(closethis);
            }
            else
                closefade();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For the past few weeks I have been working on an app that uses
I have been working on a wrapper for a COM object that can only
I’ve been working on a few small scale Access projects that have turned large
I've only been working with WPF for a few months, but I have an
I have been working in Sencha Touch for a few weeks now, and while
I have only been working with sharepoint for three months but right from the
I have been working with relational databases for sometime, but it only recently occurred
I've been using Hibernate for a few years but have only used it with
I have been writing Python code for only a couple of weeks, so I'm
I only want a list of files that have been added (not ones that

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.