Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocumentManager.cs
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocumentManager.cs	(revision 1050)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocumentManager.cs	(revision 1051)
@@ -188,5 +188,7 @@
 
             
-            _current.InitializeApp();
+            bool isEverythingOkay = _current.InitializeApp();
+
+            if (!isEverythingOkay) return;
 
             //Create the first empty document
@@ -251,7 +253,7 @@
         /// See InitializeApp(bool) below
         /// </summary>
-		private void InitializeApp()
-		{
-			InitializeApp(false);
+		private bool InitializeApp()
+		{
+			return InitializeApp(false);
 		}
 
@@ -264,5 +266,5 @@
 		/// <param name="bReLogin">Is the User logging in again from a currently running instance?
         /// If so, display a dialog to collect access and verify codes.</param>
-        private void InitializeApp(bool bReLogin)
+        private bool InitializeApp(bool bReLogin)
 		{
             //Set M connection info
@@ -278,21 +280,24 @@
             m_ConnectInfo.EventPollingEnabled = false;
 
-            //Show a splash screen while initializing
+            //Show a splash screen while initializing; define delegates to remote thread
             DSplash m_ds = new DSplash();
             DSplash.dSetStatus setStatusDelegate = new DSplash.dSetStatus(m_ds.SetStatus);
             DSplash.dAny closeSplashDelegate = new DSplash.dAny(m_ds.RemoteClose);
-            DSplash.dAny hideSplashDelegate = new DSplash.dAny(m_ds.RemoteHide);
-
+            DSplash.dProgressBarSet setMaxProgressDelegate = new DSplash.dProgressBarSet(m_ds.RemoteProgressBarMaxSet);
+            DSplash.dProgressBarSet setProgressDelegate = new DSplash.dProgressBarSet(m_ds.RemoteProgressBarValueSet);
+
+            //Start new thread for the Splash screen.
             Thread threadSplash = new Thread(new ParameterizedThreadStart(StartSplash));
-            threadSplash.IsBackground = true; //expendable -- exit even if still running.
-            threadSplash.Start(m_ds);
-
+            threadSplash.IsBackground = true; //expendable thread -- exit even if still running.
+            threadSplash.Name = "Splash Thread";
+            threadSplash.Start(m_ds); // pass form as parameter.
+
+            //There are 20 steps to load the application. That's max for the progress bar.
+            setMaxProgressDelegate(20);
             
-          	//m_ds.SetStatus("Loading Configuration Settings...");
-            //m_ds.Refresh();
-			//this.Activate();
-            // smh--not used System.Configuration.ConfigurationManager.GetSection("appSettings");
+            // smh--not used: System.Configuration.ConfigurationManager.GetSection("appSettings");
+            
             setStatusDelegate("Connecting to VISTA");
-            //m_ds.Refresh();
+            
 			bool bRetry = true;
 
@@ -301,8 +306,5 @@
             //whether you can connect or not. Not good. So I test first whether
             //we can connect at all by doing a simple connection and disconnect.
-            //TODO: Make this more robust by sending a TCPConnect message and seeing if you get a response.
-
-            //m_ds.Refresh();
-
+            //TODO: Make this more robust by sending a TCPConnect message and seeing if you get a response
             if (m_Server != "" && m_Port != 0)
             {
@@ -313,11 +315,14 @@
                     tcpClient.Close();                  // then close it
                 }
-                catch (System.Net.Sockets.SocketException ex)
+                catch (System.Net.Sockets.SocketException)
                 {
-                    throw ex;
+                    MessageBox.Show("Cannot connect to VistA. Network Error");
+                    return false;
                 }
             }
 
-			do
+			
+            // Do block is Log-in logic
+            do
 			{
                 // login crap
@@ -347,9 +352,8 @@
                 catch (System.Net.Sockets.SocketException)
                 {
-                    MessageBox.Show("Cannot connect to VistA. ");
+                    MessageBox.Show("Cannot connect to VistA. Network Error");
                 }
-                catch (Exception ex)
+                catch (BMXNetException ex)
                 {
-                    //m_ds.Close();
                     if (MessageBox.Show("Unable to connect to VistA.  " + ex.Message, "Clinical Scheduling", MessageBoxButtons.RetryCancel) == DialogResult.Retry)
                     {
@@ -361,5 +365,5 @@
                         closeSplashDelegate();
                         bRetry = false;
-                        throw ex;
+                        return false; //tell main that it's a no go.
                     }
                 }
@@ -370,5 +374,6 @@
 
 			//Version info
-            //m_ds.Activate();
+            // Table #1
+            setProgressDelegate(1);
 			setStatusDelegate("Getting Version Info from Server...");
 
@@ -406,4 +411,6 @@
 
             //Change encoding
+            // Call #2
+            setProgressDelegate(2);
             setStatusDelegate("Setting encoding...");
 
@@ -414,5 +421,8 @@
                     m_ConnectInfo.bmxNetLib.Encoder = System.Text.UTF8Encoding.UTF8;
             }
-			//Set application context
+			
+            //Set application context
+            // Call #3
+            setProgressDelegate(3);
 			setStatusDelegate("Setting Application Context to BSDXRPC...");
 			m_ConnectInfo.AppContext = "BSDXRPC";
@@ -424,6 +434,8 @@
             string sCommandText;
 
+            //Schedule User Info
+            // Table #4
+            setProgressDelegate(4);
             setStatusDelegate(statusConst + " Schedule User");
-            //Schedule User Info
             DataTable dtUser = _dal.GetUserInfo(m_ConnectInfo.DUZ);
             dtUser.TableName = "SchedulingUser";
@@ -437,12 +449,16 @@
             m_bSchedManager = (sUser == "YES") ? true : false;
 
+            //Get Access Types
+            // Table #5
+            setProgressDelegate(5);
             setStatusDelegate(statusConst + " Access Types");
-            //Get Access Types
             DataTable dtAccessTypes = _dal.GetAccessTypes();
             dtAccessTypes.TableName = "AccessTypes";
             m_dsGlobal.Tables.Add(dtAccessTypes);
 
+            //Get Access Groups
+            // Table #6
+            setProgressDelegate(6);
             setStatusDelegate(statusConst + " Access Groups");
-            //AccessGroups
             LoadAccessGroupsTable();
 
@@ -454,6 +470,8 @@
             dtGroups.PrimaryKey = dcKeys;
 
+            //Get Access Group Types (??)
+            // Table #7
+            setProgressDelegate(7);
             setStatusDelegate(statusConst + " Access Group Types");
-            //AccessGroupType
             LoadAccessGroupTypesTable();
 
@@ -471,10 +489,14 @@
             m_dsGlobal.Relations.Add(dr);
 
+            //ResourceGroup Table (Resource Groups by User)
+            // Table #8
+            setProgressDelegate(8);
             setStatusDelegate(statusConst + " Resource Groups By User");
-            //ResourceGroup Table (Resource Groups by User)
             LoadResourceGroupTable();
 
+            //Resources by user
+            // Table #9
+            setProgressDelegate(9);
             setStatusDelegate(statusConst + " Resources By User");
-            //Resources by user
             LoadBSDXResourcesTable();
 
@@ -484,6 +506,8 @@
             m_dsGlobal.Tables["Resources"].PrimaryKey = dc;
 
+            //GroupResources table
+            // Table #10
+            setProgressDelegate(10);
             setStatusDelegate(statusConst + " Group Resources");
-            //GroupResources table
             LoadGroupResourcesTable();
 
@@ -500,6 +524,8 @@
             m_dsGlobal.Relations.Add(dr);
 
+            //HospitalLocation table
+            //Table #11
+            setProgressDelegate(11);
             setStatusDelegate(statusConst + " Clinics");
-            //HospitalLocation table
             //cmd.CommandText = "SELECT BMXIEN 'HOSPITAL_LOCATION_ID', NAME 'HOSPITAL_LOCATION', DEFAULT_PROVIDER, STOP_CODE_NUMBER, INACTIVATE_DATE, REACTIVATE_DATE FROM HOSPITAL_LOCATION";
             sCommandText = "BSDX HOSPITAL LOCATION";
@@ -519,6 +545,8 @@
             m_dsGlobal.Relations.Add(dr);
 
+            //Build ScheduleUser table
+            //Table #12
+            setProgressDelegate(12);
             setStatusDelegate(statusConst + " Schedule User");
-            //Build ScheduleUser table
             this.LoadScheduleUserTable();
 
@@ -529,6 +557,8 @@
             m_dsGlobal.Tables["ScheduleUser"].PrimaryKey = dc;
 
+            //Build ResourceUser table
+            //Table #13
+            setProgressDelegate(13);
             setStatusDelegate(statusConst + " Resource User");
-            //Build ResourceUser table
             this.LoadResourceUserTable();
 
@@ -545,12 +575,16 @@
             m_dsGlobal.Relations.Add(dr);
 
+            //Build active provider table
+            //Table #14
+            setProgressDelegate(14);
             setStatusDelegate(statusConst + " Providers");
-            //Build active provider table
             sCommandText = "SELECT BMXIEN, NAME FROM NEW_PERSON WHERE INACTIVE_DATE = '' AND BMXIEN > 1";
             ConnectInfo.RPMSDataTable(sCommandText, "Provider", m_dsGlobal);
             Debug.Write("LoadGlobalRecordsets -- Provider loaded\n");
 
+            //Build the CLINIC_STOP table
+            //Table #15
+            setProgressDelegate(15);
             setStatusDelegate(statusConst + " Clinic Stops");
-            //Build the CLINIC_STOP table
             // sCommandText = "SELECT BMXIEN, CODE, NAME FROM CLINIC_STOP"; //SMH
             sCommandText = "SELECT BMXIEN, AMIS_REPORTING_STOP_CODE, NAME FROM CLINIC_STOP";
@@ -558,6 +592,8 @@
             Debug.Write("LoadGlobalRecordsets -- ClinicStop loaded\n");
 
+            //Build the HOLIDAY table
+            //Table #16
+            setProgressDelegate(16);
             setStatusDelegate(statusConst + " Holiday");
-            //Build the HOLIDAY table
             sCommandText = "SELECT NAME, DATE FROM HOLIDAY WHERE DATE > '" + DateTime.Today.ToShortDateString() + "'";
             ConnectInfo.RPMSDataTable(sCommandText, "HOLIDAY", m_dsGlobal);
@@ -568,6 +604,6 @@
             //m_dsGlobal.WriteXmlSchema(@"..\..\csSchema20060526.xsd");
             //----------------------------------------------
-            
-
+
+            setStatusDelegate("Setting Receive Timeout");
             _current.m_ConnectInfo.ReceiveTimeout = 30000; //30-second timeout
 
@@ -575,8 +611,18 @@
             _current.m_ConnectInfo.ReceiveTimeout = 600000; //longer timeout for debugging
 #endif 
-			_current.m_ConnectInfo.SubscribeEvent("BSDX SCHEDULE");
-			_current.m_ConnectInfo.SubscribeEvent("BSDX CALL WORKSTATIONS");
-			_current.m_ConnectInfo.SubscribeEvent("BSDX ADMIN MESSAGE");
-			_current.m_ConnectInfo.SubscribeEvent("BSDX ADMIN SHUTDOWN");
+			// Event Subsriptions
+            setStatusDelegate("Subscribing to Server Events");
+            //Table #17
+            setProgressDelegate(17);
+            _current.m_ConnectInfo.SubscribeEvent("BSDX SCHEDULE");
+			//Table #18
+            setProgressDelegate(18);
+            _current.m_ConnectInfo.SubscribeEvent("BSDX CALL WORKSTATIONS");
+			//Table #19
+            setProgressDelegate(19);
+            _current.m_ConnectInfo.SubscribeEvent("BSDX ADMIN MESSAGE");
+			//Table #20
+            setProgressDelegate(20);
+            _current.m_ConnectInfo.SubscribeEvent("BSDX ADMIN SHUTDOWN");
 
 			_current.m_ConnectInfo.EventPollingInterval = 5000; //in milliseconds
@@ -586,4 +632,6 @@
             //Close Splash Screen
             closeSplashDelegate();
+
+            return true;
 			
 		}
Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj.user
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj.user	(revision 1050)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/ClinicalScheduling.csproj.user	(revision 1051)
@@ -37,5 +37,5 @@
     </RemoteDebugMachine>
     <StartAction>Project</StartAction>
-    <StartArguments>/s=10.161.20.25 /p=9280 /a=s.habiel /v=catdog.55</StartArguments>
+    <StartArguments>/s=192.168.56.101 /p=9260 /a=shabiel12 /v=catdog.66</StartArguments>
     <StartPage>
     </StartPage>
Index: Scheduling/trunk/cs/bsdx0200GUISourceCode/DSplash.cs
===================================================================
--- Scheduling/trunk/cs/bsdx0200GUISourceCode/DSplash.cs	(revision 1050)
+++ Scheduling/trunk/cs/bsdx0200GUISourceCode/DSplash.cs	(revision 1051)
@@ -17,4 +17,5 @@
         private Label lblVersion;
         private Label label2;
+        private ProgressBar progressBar1;
 		/// <summary>
 		/// Required designer variable.
@@ -62,4 +63,5 @@
             this.lblVersion = new System.Windows.Forms.Label();
             this.label2 = new System.Windows.Forms.Label();
+            this.progressBar1 = new System.Windows.Forms.ProgressBar();
             this.SuspendLayout();
             // 
@@ -110,4 +112,12 @@
             this.label2.Text = "VISTA";
             // 
+            // progressBar1
+            // 
+            this.progressBar1.Location = new System.Drawing.Point(18, 207);
+            this.progressBar1.Name = "progressBar1";
+            this.progressBar1.Size = new System.Drawing.Size(458, 14);
+            this.progressBar1.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
+            this.progressBar1.TabIndex = 7;
+            // 
             // DSplash
             // 
@@ -116,4 +126,5 @@
             this.ClientSize = new System.Drawing.Size(488, 252);
             this.ControlBox = false;
+            this.Controls.Add(this.progressBar1);
             this.Controls.Add(this.label2);
             this.Controls.Add(this.lblVersion);
@@ -135,4 +146,5 @@
         public delegate void dSetStatus(string sStatus);
         public delegate void dAny();
+        public delegate void dProgressBarSet(int number);
 		
         public void SetStatus(string sStatus)
@@ -145,7 +157,5 @@
             }
             
-            System.Diagnostics.Debug.Assert(this.InvokeRequired == false);
 			this.lblStatus.Text = sStatus;
-            this.Refresh();
 		}
 
@@ -166,4 +176,29 @@
             this.Invoke(d);
         }
+
+        public void RemoteProgressBarMaxSet(int max)
+        {
+            if (this.InvokeRequired == true)
+            {
+                dProgressBarSet d = new dProgressBarSet(RemoteProgressBarMaxSet);
+                this.Invoke(d, new object[] { max });
+                return;
+            }
+
+            this.progressBar1.Maximum = max;
+        }
+
+        public void RemoteProgressBarValueSet(int val)
+        {
+            if (this.InvokeRequired == true)
+            {
+                dProgressBarSet d = new dProgressBarSet(RemoteProgressBarValueSet);
+                this.Invoke(d, new object[] { val });
+                return;
+            }
+
+            this.progressBar1.Value = val;
+        }
+
 	}
 
