none
Thread is Being Aborted RRS feed

  • Question

  • I am using WCF application in which i created thread as below,

    This is getting below error while doing DB updatations

    THREAD WAS BEING ABORTED.
    SYSTEM.THREADING.THREADABORTEXCEPTION: THREAD WAS BEING ABORTED.

    Below is my thread creation in Application

                                       

    new System.Threading.Thread(
                                    () =>
                                    {

                                       Processrequest();

                                          }).Start();

    Please help if any correction or extra things to be added in code.

    Thanks & Regards,

    Santhosh Kumar,

    +91-9901535163.

    Tuesday, January 10, 2017 12:24 PM

All replies

  • Hi Santhu.net,

    To check whether it is related with DB update operation, I would suggest you add new simple methods which returns a simple string. Did this issue still exist? If you update database with the same code in winform, did this issue still exist? To check the detailed error, I would suggest you try Configuring Tracing.

    I made a test with below code, the DB updates correctly.

    //WCF Service
            public bool UpdateTable(int id, string userName)
            {
                bool isUpdated=false;
                try
                {
                    new System.Threading.Thread(()=> {
                        TestDbEntities testDb = new TestDbEntities();
                        tblUser tblUserRecord = testDb.tblUsers.SingleOrDefault(u => u.Id == id);
                        tblUserRecord.UserName = userName;
                        testDb.SaveChanges();
                    }).Start();
                    isUpdated = true;
                }
                catch (Exception)
                {
                    isUpdated = false;                
                }
                return isUpdated;
            }
    //WCF Client
                DbOperationService.DbOperationClient dbOperation = new DbOperationService.DbOperationClient();
                bool isUpdated= dbOperation.UpdateTable(2,"T");
                MessageBox.Show(isUpdated.ToString());

    It would be helpful if you could share us detailed steps and code which could reproduce your issue.

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, January 11, 2017 2:58 AM