• Welcome to Valhalla Legends Archive.
 

WTF Error

Started by Imperceptus, April 26, 2008, 09:01 AM

Previous topic - Next topic

Imperceptus

Happens randomly in my socket class.  Is this from a memory leak?


The Undo operation encountered a context that is different from what was applied in the corresponding Set operation. The possible cause is that a context was Set on the thread and not reverted(undone).
Quote from: Hazard on August 07, 2003, 03:15 PM
Highlight your entire code. Press the delete key. Start over again using Cuphead's CSB tutorial and work your way from their rather than raping code from downloaded sources meant purely for learning purposes. If this does not fix the problem, uninstall Visual Basic and get a new hobby. I suggest Cricket.

brew

#1
Quote from: Imperceptus on April 26, 2008, 09:01 AM
Is this from a memory leak?

Probably not. It seems to have something to do with multithreaded applications, perhaps something dealing with the winsock's asynchronus events?
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

Imperceptus

Yeah. I have plenty of asynchronous socket stuff going on.  Tracked it down into my send procedure after the sync lock. might need to rebuild the class smarter. joy.
Quote from: Hazard on August 07, 2003, 03:15 PM
Highlight your entire code. Press the delete key. Start over again using Cuphead's CSB tutorial and work your way from their rather than raping code from downloaded sources meant purely for learning purposes. If this does not fix the problem, uninstall Visual Basic and get a new hobby. I suggest Cricket.

MyndFyre

Are you doing:
* Application.DoEvents()
* Updating your GUI
* Using Remoting across thread boundaries

in your application?

From what I've seen here it seems to indicate that you're updating the user interface across thread boundaries.  This is not permitted in Win32; use the ISynchronizeInvoke interface (exposed by the Control class) to marshal your update calls back to the UI thread.

Generally I don't like working with async sockets.  I do all the marshaling myself.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Imperceptus

#4
I have no clue how to do the marshaling myself. and yes i am beginning to hate async sockets.

I think its happening after the synclock. Im not too sure because the error doesn't point out whats doing it. so i put debug statements around and this is the last  print before the error.


    Public Sub Send(ByVal Message As String)
        Debug.Print("send")

       
        Dim bytes() As Byte = _
            System.Text.ASCIIEncoding.ASCII.GetBytes(Message)
        Try
            SyncLock _Socket
                _Socket.Send(bytes, bytes.Length, SocketFlags.None)
            End SyncLock
            RaiseEvent DataSent(Message)
        Catch ex As Exception
            RaiseEvent SocketError(ex)
        End Try
    End Sub


I do have the base of the project written in vb6 (got tired of this stupid error in .net) , but I would really like to know how to accomplish it in .net.
Quote from: Hazard on August 07, 2003, 03:15 PM
Highlight your entire code. Press the delete key. Start over again using Cuphead's CSB tutorial and work your way from their rather than raping code from downloaded sources meant purely for learning purposes. If this does not fix the problem, uninstall Visual Basic and get a new hobby. I suggest Cricket.

MyndFyre

Using SyncLock/lock (the Monitor class) doesn't synchronize threading to the UI thread.  It synchronizes access to a section of code via an instance of an object.

In order to synchronize UI updates you use the ISynchronizeInvoke interface.  For instance:


Private Delegate Sub AddChatCallback(ByVal text As String, ByVal color As Color

Private Sub AddChatImpl(ByVal text As String, ByVal color As Color)
    ' the addchat code
End Sub

Public Sub AddChat(ByVal text As String, ByVal col As Color)
    Dim ac As New AddChatCallback(Me.AddChatImpl)
    Dim parameters(2) As Object
    parameters(0) = text
    parameters(1) = col
    If richTextBox.InvokeRequired Then
        richTextBox.BeginInvoke(ac, parameters)
    Else
        ac(text, col)
End Sub
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Warrior

Quote from: Imperceptus on April 27, 2008, 01:18 PM
I have no clue how to do the marshaling myself. and yes i am beginning to hate async sockets.

I think its happening after the synclock. Im not too sure because the error doesn't point out whats doing it. so i put debug statements around and this is the last  print before the error.


    Public Sub Send(ByVal Message As String)
        Debug.Print("send")

      
        Dim bytes() As Byte = _
            System.Text.ASCIIEncoding.ASCII.GetBytes(Message)
        Try
            SyncLock _Socket
                _Socket.Send(bytes, bytes.Length, SocketFlags.None)
            End SyncLock
            RaiseEvent DataSent(Message)
        Catch ex As Exception
            RaiseEvent SocketError(ex)
        End Try
    End Sub


I do have the base of the project written in vb6 (got tired of this stupid error in .net) , but I would really like to know how to accomplish it in .net.

This may be off base, bur assuming you're writing a client application why not use blocking i/o?
Probably a hell of a lot less complex than Async sockets.

Spawn one or two threads and bam you're done.
Quote from: effect on March 09, 2006, 11:52 PM
Islam is a steaming pile of fucking dog shit. Everything about it is flawed, anybody who believes in it is a terrorist, if you disagree with me, then im sorry your wrong.

Quote from: Rule on May 07, 2006, 01:30 PM
Why don't you stop being American and start acting like a decent human?

MyndFyre

The only problem with doing blocking I/O is that the number of wait handles becomes unwieldy on server applications.  But yes, it's way easier to managed.  (Although you still need to use ISynchronizeInvoke if you're on a background thread).
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Imperceptus

I will have to put it on my list of things to learn how to do.  that list is dwindling fast work went from challenging to not challenging by any programmer.
Quote from: Hazard on August 07, 2003, 03:15 PM
Highlight your entire code. Press the delete key. Start over again using Cuphead's CSB tutorial and work your way from their rather than raping code from downloaded sources meant purely for learning purposes. If this does not fix the problem, uninstall Visual Basic and get a new hobby. I suggest Cricket.