Ignore:
Timestamp:
Jan 26, 2011, 5:45:02 AM (13 years ago)
Author:
Sam Habiel
Message:

BMX version bumped to 2.3.
New dll
BMXNetConnectInfo: Event polling from RPMS/VISTA is now async. BMX Writer lock removed.
BMXNetLib:

  1. Application context changes are now suppressed. Developer must make sure that his/her application has all the needed BMX methods. This was done for performance enhancement as application context changes are very expensive in network time.
  2. Locks are implemented at the TransmitRPC with a very simple Lock(this) which works very well.

RPMSDb: See #1 for BMXNetLib. All context changes are now suppressed.

Location:
BMXNET_RPMS_dotNET_UTILITIES-BMX/trunk/cs/bmx_0200scr/BMX2/BMXNet
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • BMXNET_RPMS_dotNET_UTILITIES-BMX/trunk/cs/bmx_0200scr/BMX2/BMXNet/AssemblyInfo.cs

    r967 r1082  
    2828// by using the '*' as shown below:
    2929
    30 [assembly: AssemblyVersion("2.2.0.*")]
     30[assembly: AssemblyVersion("2.3.0.*")]
    3131
    3232//
     
    5858//[assembly: AssemblyKeyFile("")]
    5959//[assembly: AssemblyKeyName("")]
    60 [assembly: AssemblyFileVersionAttribute("2.2.0.0")]
     60[assembly: AssemblyFileVersionAttribute("2.3.0.0")]
    6161[assembly: ComVisibleAttribute(false)]
  • BMXNET_RPMS_dotNET_UTILITIES-BMX/trunk/cs/bmx_0200scr/BMX2/BMXNet/BMXNet.csproj

    r1063 r1082  
    1212    <AssemblyKeyContainerName>
    1313    </AssemblyKeyContainerName>
    14     <AssemblyName>BMXNet22</AssemblyName>
     14    <AssemblyName>BMXNet23</AssemblyName>
    1515    <AssemblyOriginatorKeyFile>wv.key.snk</AssemblyOriginatorKeyFile>
    1616    <DefaultClientScript>JScript</DefaultClientScript>
     
    2929    <SignAssembly>false</SignAssembly>
    3030    <OldToolsVersion>3.5</OldToolsVersion>
    31     <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
     31    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    3232    <PublishUrl>publish\</PublishUrl>
    3333    <Install>true</Install>
  • BMXNET_RPMS_dotNET_UTILITIES-BMX/trunk/cs/bmx_0200scr/BMX2/BMXNet/BMXNetConnectInfo.cs

    r1063 r1082  
    1313using System.Timers;
    1414using System.Threading;
     15using System.Runtime.Remoting.Messaging;
    1516
    1617
     
    228229                        try
    229230                        {
    230                                 this.bmxNetLib.BMXRWL.AcquireWriterLock(5);
     231                                //this.bmxNetLib.BMXRWL.AcquireWriterLock(5);
    231232                                try
    232233                                {
     
    265266                        }
    266267                        RPMSDataTableDelegate rdtd = new RPMSDataTableDelegate(RPMSDataTable);
    267                                                 dtEvents = (DataTable) this.Invoke(rdtd, new object[] {"BMX EVENT POLL", "BMXNetEvents"});
    268                                         }
     268                                               
     269                        //SMH - 3100110 - BMX EVENT POLL happens in the foreground. It blocks the main thread
     270                        //until it is done. So I changed it to async so that there would be no jerking
     271                        //on this thread while it's taking place.
     272                        //dtEvents = (DataTable) this.Invoke(rdtd, new object[] {"BMX EVENT POLL", "BMXNetEvents"});
     273                       
     274                        rdtd.BeginInvoke("BMX EVENT POLL", "BMXNetEvents", new AsyncCallback(BMXNetEventsCallback), null);
     275                    }
    269276                                        catch (Exception ex)
    270277                                        {
     
    273280                                                return;
    274281                                        }
    275 
     282                    /*
    276283                                        try
    277284                                        {
     
    286293                                                Debug.Write("upper Exception in BMXNetConnectInfo.OnEventTimer: " + ex.Message + "\n");
    287294                                        }
     295                   
    288296                                        try
    289297                                        {
     
    305313                                                Debug.Write("lower Exception in BMXNetConnectInfo.OnEventTimer: " + ex.Message + "\n");
    306314                                        }
     315                    */
    307316                                }
    308317                                catch(Exception ex)
     
    310319                                        Debug.Write("Exception in BMXNetConnectInfo.OnEventTimer: " + ex.Message + "\n");
    311320                                }
    312                                 finally
    313                                 {
    314                                         this.bmxNetLib.BMXRWL.ReleaseWriterLock();
    315                                         this.m_timerEvent.Enabled = true;
    316                                 }
    317                         }
     321                finally
     322                {
     323                    //this.bmxNetLib.BMXRWL.ReleaseWriterLock();
     324                    //this.m_timerEvent.Enabled = true;
     325                }
     326               
     327            }
    318328                        catch
    319329                        {
     
    321331                        }
    322332                }
     333
     334       
     335        /// <summary>
     336        /// Callback for Async operation to get events from RPMS/VISTA server
     337        /// </summary>
     338        /// <param name="itfAR"></param>
     339        void BMXNetEventsCallback(IAsyncResult itfAR)
     340        {
     341            //Define datatable we will receive results at.
     342            DataTable dtEvents;
     343            //Get Result
     344            AsyncResult ar = (AsyncResult)itfAR;
     345            //Get Original Delegate
     346            RPMSDataTableDelegate rdtd = (RPMSDataTableDelegate)ar.AsyncDelegate;
     347           
     348            //Complete the call of the delegate. We may lose connection so try catch
     349            try
     350            {
     351                dtEvents = rdtd.EndInvoke(itfAR);
     352            }
     353            catch (Exception ex)
     354            {
     355                throw new BMXNetException("Lost connection to Server", ex);
     356            }
     357
     358            BMXNetEventArgs args = new BMXNetEventArgs();
     359           
     360            //Fire off BMXNetEvent to interested subscribers
     361            if (dtEvents.Rows.Count != 0)
     362            {
     363                foreach (DataRow dr in dtEvents.Rows)
     364                {
     365                    args.BMXEvent = dr["EVENT"].ToString();
     366                    args.BMXParam = dr["PARAM"].ToString();
     367                    if (BMXNetEvent != null)
     368                    {
     369                        BMXNetEvent(this, args);
     370                    }
     371                }
     372            }
     373
     374            //re-enable the timer so it can check again for events
     375           
     376            this.m_timerEvent.Enabled = true;
     377        }
    323378
    324379                #endregion BMXNetEvent
  • BMXNET_RPMS_dotNET_UTILITIES-BMX/trunk/cs/bmx_0200scr/BMX2/BMXNet/BMXNetLib.cs

    r1063 r1082  
    10271027                        try
    10281028                        {
    1029                                 string sContext = this.AppContext;
    1030                                 this.AppContext = "BMXRPC";
     1029                /* 3110109 -- smh Commented out for performance issues.
     1030                                /*string sContext = this.AppContext;
     1031                                this.AppContext = "BMXRPC";*/
    10311032                                Variable = Variable.Replace("^","~");
    10321033                                string sRet = "0";
     
    10351036                                sRet = TransmitRPC("BMX LOCK", sParam);
    10361037                                bRet = (sRet == "1")?true:false;
    1037                                 this.AppContext = sContext;
     1038                /* 3110109 -- smh Commented out for performance issues.
     1039                                /*this.AppContext = sContext;*/
    10381040                                return bRet;
    10391041                        }
     
    10771079                public string TransmitRPC(string sRPC, string sParam, int nLockTimeOut)
    10781080                {
    1079                         try
    1080                         {
    1081                                 try
    1082                                 {
    1083                                         if (m_bConnected == false)
    1084                                         {
    1085                                                 throw new BMXNetException("BMXNetLib.TransmitRPC failed because BMXNetLib is not connected to RPMS.");
    1086                                         }
    1087                                         Debug.Assert(m_cDUZ != "");
    1088                                         Debug.Assert(m_pCommSocket != null);
    1089 
    1090                                         string sOldAppContext = "";
    1091                                         if (sRPC.StartsWith("BMX")&&(this.m_cAppContext != "BMXRPC"))
    1092                                         {
    1093                                                 sOldAppContext  = this.m_cAppContext;
    1094                                                 this.AppContext = "BMXRPC";
    1095                                         }
    1096                                         string sMult = "";
    1097                                         string sSend = ADEBLDMsg(m_cHDR, sRPC, sParam, ref sMult);
    1098                                         SendString(m_pCommSocket, sSend, sMult);
    1099 #if TRACE   
    1100                     DateTime sendTime = DateTime.Now;
    1101                     Debug.Write("TransmitRPC Sent: " + sSend.Replace((char) 30, (char) 10) + "\n");
     1081            lock (this)  // This method CANNOT be executed simultaneously!
     1082            {
     1083                try
     1084                {
     1085                    try
     1086                    {
     1087                        if (m_bConnected == false)
     1088                        {
     1089                            throw new BMXNetException("BMXNetLib.TransmitRPC failed because BMXNetLib is not connected to RPMS.");
     1090                        }
     1091                        Debug.Assert(m_cDUZ != "");
     1092                        Debug.Assert(m_pCommSocket != null);
     1093
     1094                        string sOldAppContext = "";
     1095                        /* 3110109 -- smh Commented out for performance issues.
     1096                         if (sRPC.StartsWith("BMX")&&(this.m_cAppContext != "BMXRPC"))
     1097                        {
     1098                            sOldAppContext  = this.m_cAppContext;
     1099                            this.AppContext = "BMXRPC";
     1100                        }
     1101                         */
     1102                        string sMult = "";
     1103                        string sSend = ADEBLDMsg(m_cHDR, sRPC, sParam, ref sMult);
     1104                        SendString(m_pCommSocket, sSend, sMult);
     1105#if TRACE
     1106                        DateTime sendTime = DateTime.Now;
     1107                        int threadid = Thread.CurrentThread.ManagedThreadId;
     1108                        Debug.Write("TransmitRPC Sent: (T:" + threadid + ")" + sSend.Replace((char)30, (char)10) + "\n");
    11021109#endif
    1103                     string strResult = ReceiveString(m_pCommSocket);
     1110                        string strResult = ReceiveString(m_pCommSocket);
    11041111#if TRACE
    1105                     DateTime receiveTime = DateTime.Now;
    1106                     Debug.Write("TransmitRPC Received: " + strResult.Replace((char) 30, (char) 10) + "\n");
    1107                     TimeSpan executionTime = receiveTime - sendTime;
    1108                     Debug.Write("Execution Time: " + executionTime.TotalMilliseconds + " ms.\n");
    1109                     Debug.Write("-------------------------------------------------------\n");
     1112                        DateTime receiveTime = DateTime.Now;
     1113                        Debug.Write("TransmitRPC Received: (T:" + threadid + ")" + strResult.Replace((char)30, (char)10) + "\n");
     1114                        TimeSpan executionTime = receiveTime - sendTime;
     1115                        Debug.Write("Execution Time: " + executionTime.TotalMilliseconds + " ms.\n");
     1116                        Debug.Write("-------------------------------------------------------\n");
    11101117#endif
    1111                                         if (sOldAppContext != "")
     1118                        /* /* 3110109 -- smh Commented out for performance issues.
     1119                     * if (sOldAppContext != "")
    11121120                                        {
    11131121                                                this.AppContext = sOldAppContext;
    11141122                                        }
    1115                                         return strResult;                               
    1116                                 }
    1117                                 catch (Exception ex)
    1118                                 {
    1119                                         if (ex.Message == "Unable to write data to the transport connection.")
    1120                                         {
    1121                                                 m_bConnected = false;
    1122                                         }
    1123                                         throw ex;
    1124                                 }
    1125                                 finally
    1126                                 {
    1127                                 }                       
    1128                         }
    1129                         catch (ApplicationException aex)
    1130                         {
    1131                                 // The writer lock request timed out.
    1132                                 Debug.Write("TransmitRPC writer lock request timed out.\n");
    1133                                 throw aex;
    1134                         }
    1135                         catch (Exception OuterEx)
    1136                         {
    1137                                 throw OuterEx;
    1138                         }
     1123                     */
     1124                        return strResult;
     1125                    }
     1126                    catch (Exception ex)
     1127                    {
     1128                        if (ex.Message == "Unable to write data to the transport connection.")
     1129                        {
     1130                            m_bConnected = false;
     1131                        }
     1132                        throw ex;
     1133                    }
     1134                    finally
     1135                    {
     1136                    }
     1137                }
     1138                catch (ApplicationException aex)
     1139                {
     1140                    // The writer lock request timed out.
     1141                    Debug.Write("TransmitRPC writer lock request timed out.\n");
     1142                    throw aex;
     1143                }
     1144                catch (Exception OuterEx)
     1145                {
     1146                    throw OuterEx;
     1147                }
     1148            }
    11391149                }
    11401150
  • BMXNET_RPMS_dotNET_UTILITIES-BMX/trunk/cs/bmx_0200scr/BMX2/BMXNet/RPMSDb.cs

    r822 r1082  
    8787                {
    8888                        string sRPC;
    89                         string sOldContext = m_rpx.AppContext;
    90 
    91                         if (m_rpx.AppContext != "BMXRPC")
    92                         {
    93                                 m_rpx.AppContext = "BMXRPC";
    94                         }
     89
     90            /* /* 3110109 -- smh Commented out for performance
     91            string sOldContext = m_rpx.AppContext;
     92
     93            if (m_rpx.AppContext != "BMXRPC")
     94            {
     95                m_rpx.AppContext = "BMXRPC";
     96            }
     97             */
    9598
    9699                        sRPC = "BMX UPDATE";
     
    98101                        m_sCmd = m_sCmd.Substring(nStart);
    99102                        string sResult = m_rpx.TransmitRPC( sRPC,  m_sCmd);
    100                        
    101                         if (sOldContext != m_rpx.AppContext)
    102                         {
    103                                 m_rpx.AppContext = sOldContext;
    104                         }
     103
     104            /* /* 3110109 -- smh Commented out for performance
     105            if (sOldContext != m_rpx.AppContext)
     106            {
     107                m_rpx.AppContext = sOldContext;
     108            }
     109             */
    105110
    106111                        resultset = new RPMSDbResultSet();
     
    113118                        string sRPC;
    114119                        string sParam;
    115                         string sOldContext = m_rpx.AppContext;
    116                         if (m_sQueryType == "SELECT")
    117                         {
    118                                 if (m_rpx.AppContext != "BMXRPC")
    119                                 {
    120                                         m_rpx.AppContext = "BMXRPC";
    121                                 }
     120            /* /* 3110109 -- smh Commented out for performance issues.
     121            string sOldContext = m_rpx.AppContext;
     122            */
     123            if (m_sQueryType == "SELECT")
     124                        {
     125                /*/* 3110109 -- smh Commented out for performance issues.
     126                if (m_rpx.AppContext != "BMXRPC")
     127                {
     128                    m_rpx.AppContext = "BMXRPC";
     129                }
     130                 */
    122131                                sRPC = "BMX SQL";
    123132                                sParam = m_sCmd;
     
    131140                        string sResult = m_rpx.TransmitRPC( sRPC,  sParam);
    132141                       
     142            /*
    133143                        if (sOldContext != m_rpx.AppContext)
    134144                        {
    135145                                m_rpx.AppContext = sOldContext;
    136146                        }
     147             */
    137148                       
    138149                        return sResult;
Note: See TracChangeset for help on using the changeset viewer.