Results 1 to 5 of 5

Thread: ContextSwitchDeadlock Error

  1. #1

    Thread Starter
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    ContextSwitchDeadlock Error

    I get the ContextSwitchDeadlock Error when I set try to RichTextBox text to some large text, empty it and then set it to some other large text again.

    This is what I'm doing:
    1. RichTextBox1.Text = SomeLargeString
    2. RichTextBox1.Text = EmptyString
    3. (do some other stuff here)
    4. RichTextBox1.Text = SomeOtherLargeString

    The SomeOtherLargeString is smaller than SomeLargeString, but error occurs on that line.

    Anyone has any ideas about this?
    Attached Images Attached Images  
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: ContextSwitchDeadlock Error

    What happens if you remove step 3? Do you still get the same error?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: ContextSwitchDeadlock Error

    The immediate previous line to step 4 works successfully. It is actually a function call that outputs the SomeOtherLargeString. Then the yellow marker comes to line in step 4. When I press F10 there it takes a long time and finally shows this error.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: ContextSwitchDeadlock Error

    What happens if you remove step 3? Do you still get the same error?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: ContextSwitchDeadlock Error

    Quote Originally Posted by jmcilhinney View Post
    What happens if you remove step 3? Do you still get the same error?
    That's surprising!
    It works ok if I remove that step.

    Actually what I'm doing there is - load the current richtextbox text into a webbrowser control. Then process that data and finally put the processed result back into richtextbox. The data is html type and the process basically transposes some tables etc. in it.

    Code:
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            WebBrowser1.BringToFront()
            WebBrowser1.DocumentText = RichTextBox1.Text
            RichTextBox1.Text = ""
            EnsureWebBrowserIsReady()
            Dim result As String = "<TABLE>" & ProcessStage2() & "</TABLE>"
            RichTextBox1.Text = result
            RichTextBox1.BringToFront()
        End Sub
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width