-----------------------------------------------------------

New Message on MumbaiUserGroup

-----------------------------------------------------------
From: Kripak
Message 1 in Discussion

I have a main class that creates a Thread pool from the Thread Class

 

                            ClsThread[] objClsThread1 = new 
ClsThread[ThreadInstances];

                            // Queue up  work items in the ThreadPool.

                            for (threadNum = 0; threadNum <= ThreadInstances - 
1; threadNum++)

                            {

                                objClsThread1[threadNum] = new 
ClsThread("ConvID" + threadNum, mProcessName.ToLower().Trim());

                                ThreadPool.QueueUserWorkItem(new 
WaitCallback(AccessClassResource), objClsThread1[threadNum]);

 

                            }

 

 

 

 

 

 

The Main class calls this method  from the thread pool which invokes the 
connectToWebService method in the Thread Class

        public static void AccessClassResource(object state)

        {

 

 

            int threadUsage = 
Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["ThreadInstances"]);

            ClsThread objClsThread = (ClsThread)state;

            bool isSessionValid = objClsThread.connectToWebService();

 

 

            if (isSessionValid)

            {

                //if (Interlocked.Decrement(ref ThreadInstances) == 0)

                if (Interlocked.Decrement(ref threadUsage) == 0)

                {

                    Done.Set();

                }

                cnt = cnt + 1;

            }

 

 

            System.Environment.Exit(0);

 

 

        }

 

The Thread Class has this method which does the entire activity in a lock . The 
activity done within a lock is very crucial and Time consuming.We are looking 
out for a way by which we can create delegates for the threads and these 
delegates can take up the activities in parts or can there be any asynchronous 
calls.This should reduce the time consumption for execution.

 

 

#region Connect To WebService

        /// <summary>

        /// To connect to SABRE webservice for various operations 

        /// </summary>

        public bool connectToWebService()

        {

            bool success = false;

            int status = 0;

            

            

            try

            {

                Thread.Sleep(1000);

                

               arrSessionSettings = 
objClsSabreWSOperation.CreateWSSession(this.ConvId);

               ClsUtilities.LogInfo("Session Created" + DateTime.Now, true);

                if (arrSessionSettings.Count > 0)

                {

                    ClsUtilities objUtility = new ClsUtilities();

                    

                    while (iTickets < mArrTicketNumbers.Count)

                    {

                        if (iTickets >= 500)

                        {

                            this.Dispose();

                            GC.Collect();

                            System.Environment.Exit(0);

                        }

 

                        passTicketNumber();

                        lock (this)

                        {

                          

                            try

                            {

                                Console.WriteLine("Starting Initiate Tasks" + 
mArrTicketNumbers[iPNR - 1].ToString() + this.ConvId);

                                
objClsActions.InitiateTasks(mArrTicketNumbers[iTickets - 1].ToString(), 
arrSessionSettings, this.RuleSetName);

 

 

                            }

                            catch (Exception ex)

                            {

                   status = objLog.Log(ClsQRFeed.Process_Action_RelationID, 
ex.StackTrace.ToString(), ex.Message.ToString(), "Application", 
mArrTicketNumbers[iTickets - 1].ToString(), "ClsThread", "connectToWebService");

                            }

                            finally

                            {

 

                            }

 

                        }

 

                    }

 

                    objClsSabreWSOperation.CloseWSSession(arrSessionSettings);

                }

                else

                {

                     success= false;

                }

 

                success = true;  

            }

            catch (Exception ex)

            {

 

               throw ex;                

            }

            finally

            {

                              

            }

            return success;

            

        }

        #endregion


-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/mumbaiusergroup/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to