Link to home
Start Free TrialLog in
Avatar of malich1
malich1

asked on

Executing C# Screensaver on 2+ monitors

I am in the process of making a screensaver that spans multiple monitors but I have one problem. Its with this code:

             for (int i = Screen.AllScreens.GetLowerBound(0);
      i <= Screen.AllScreens.GetUpperBound(0); i++)
      System.Windows.Forms.Application.Run(new InfoSaver.InfoSaverForm(i));

You will see that it is useing the Application run and this will start the screensaver on the first monitor but it then waits for the screansaver to be closed before starting the second monitor. how do i change this to get it to fire on both??
Avatar of joshpowers
joshpowers
Flag of United States of America image

I would think a good start would be to run them in seperate threads instead of using Application.Run
Using System.Threading
Avatar of malich1
malich1

ASKER

I understand how to do that in VB.net but not in C#. What needs to be done?
ASKER CERTIFIED SOLUTION
Avatar of joshpowers
joshpowers
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of malich1

ASKER

Maybe this will help:
using System;
using System.Windows.Forms;

namespace InfoSaverF
{
      public class DotNETScreenSaver
      {
            [STAThread]
            static void Main(string[] args)
        {
                  InfoSaver.InfoSaverForm[]frm;
                  frm = new InfoSaver.InfoSaverForm[Screen.AllScreens.Length];

                  if (args.Length > 0)
                  {
                        if (args[0].ToLower().Trim().Substring(0,2) == "/c")
                        {
                              MessageBox.Show("This Screen Saver has no options you can set.", "InfoSaver", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        else if (args[0].ToLower() == "/s")
                        {
                              MessageBox.Show("This Screen Saver has no options you can set.", "InfoSaver", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                  }
                  else
                  {
                  for (int i = Screen.AllScreens.GetLowerBound(0); i <= Screen.AllScreens.GetUpperBound(0); i++)
                  frm[Screen.AllScreens.GetLowerBound(0)-i]=new InfoSaver.InfoSaverForm(i);
                  }
            }
      }
}