Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Error with converted c# code

Posted on 2014-03-29
7
Medium Priority
?
62 Views
Last Modified: 2016-06-20
Hello i have this vb code and i am not sure how to resolve this erorr

here is my function
    Private Shared Sub Main(args As String())
        Dim engine As EmoEngine = EmoEngine.Instance

        engine.EmoEngineConnected += New EmoEngine.EmoEngineConnectedEventHandler(AddressOf engine_EmoEngineConnected)
        engine.EmoEngineDisconnected += New EmoEngine.EmoEngineDisconnectedEventHandler(AddressOf engine_EmoEngineDisconnected)
        engine.UserAdded += New EmoEngine.UserAddedEventHandler(AddressOf engine_UserAdded)
        engine.UserRemoved += New EmoEngine.UserRemovedEventHandler(AddressOf engine_UserRemoved)
        engine.EmoStateUpdated += New EmoEngine.EmoStateUpdatedEventHandler(AddressOf engine_EmoStateUpdated)
        engine.ExpressivEmoStateUpdated += New EmoEngine.ExpressivEmoStateUpdatedEventHandler(AddressOf engine_ExpressivEmoStateUpdated)
        engine.CognitivEmoStateUpdated += New EmoEngine.CognitivEmoStateUpdatedEventHandler(AddressOf engine_CognitivEmoStateUpdated)
        engine.AffectivEmoStateUpdated += New EmoEngine.AffectivEmoStateUpdatedEventHandler(AddressOf engine_AffectivEmoStateUpdated)
        engine.EmoEngineEmoStateUpdated += New EmoEngine.EmoEngineEmoStateUpdatedEventHandler(AddressOf engine_EmoEngineEmoStateUpdated)
        engine.CognitivTrainingStarted += New EmoEngine.CognitivTrainingStartedEventEventHandler(AddressOf engine_CognitivTrainingStarted)
        engine.CognitivTrainingSucceeded += New EmoEngine.CognitivTrainingSucceededEventHandler(AddressOf engine_CognitivTrainingSucceeded)
        engine.CognitivTrainingCompleted += New EmoEngine.CognitivTrainingCompletedEventHandler(AddressOf engine_CognitivTrainingCompleted)
        engine.CognitivTrainingRejected += New EmoEngine.CognitivTrainingRejectedEventHandler(AddressOf engine_CognitivTrainingRejected)
        engine.ExpressivTrainingStarted += New EmoEngine.ExpressivTrainingStartedEventEventHandler(AddressOf engine_ExpressivTrainingStarted)
        engine.ExpressivTrainingSucceeded += New EmoEngine.ExpressivTrainingSucceededEventHandler(AddressOf engine_ExpressivTrainingSucceeded)
        engine.ExpressivTrainingCompleted += New EmoEngine.ExpressivTrainingCompletedEventHandler(AddressOf engine_ExpressivTrainingCompleted)
        engine.ExpressivTrainingRejected += New EmoEngine.ExpressivTrainingRejectedEventHandler(AddressOf engine_ExpressivTrainingRejected)

        engine.Connect()

        Dim cki As New ConsoleKeyInfo()
        ' int x, y;

        While True
            Try
                If Console.KeyAvailable Then
                    cki = Console.ReadKey(True)
                    keyHandler(cki.Key)

                    If cki.Key = ConsoleKey.X Then
                        Exit Try
                    End If
                End If


                'engine.HeadsetGetGyroDelta(0, out x, out y);
                'if (x!=0 || y!=0)
                '    Console.WriteLine("{0}, {1}", x, y);
                engine.ProcessEvents(1000)
            Catch e As EmoEngineException
                Console.WriteLine("{0}", e.ToString())
            Catch e As Exception
                Console.WriteLine("{0}", e.ToString())
            End Try
        End While
        engine.Disconnect()
    End Sub

Open in new window


i am getting this erorr

Error      4      'Public Event EmoEngineDisconnected(sender As Object, e As Emotiv.EmoEngineEventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.      C:\Users\lauren\SkyDrive\Research\LMS\EEGProject\EEGResearchProject\EEGResearchProject\EEG.vb      297      9      EEGResearchProject
0
Comment
Question by:Chris Jones
  • 4
  • 2
6 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 total points
ID: 39963726
I think the problem is with your event registration section. You need to use "AddHandler" rather than the C# style of +=:
AddHandler engine.EmoEngineConnected, AddressOf engine_EmoEngineConnected
AddHandler engine.EmoEngineDisconnected, AddressOf engine_EmoEngineDisconnected
AddHandler engine.UserAdded, AddressOf engine_UserAdded
AddHandler engine.UserRemoved, AddressOf engine_UserRemoved
AddHandler engine.EmoStateUpdated, AddressOf engine_EmoStateUpdated
AddHandler engine.ExpressivEmoStateUpdated, AddressOf engine_ExpressivEmoStateUpdated
AddHandler engine.CognitivEmoStateUpdated, AddressOf engine_CognitivEmoStateUpdated
AddHandler engine.AffectivEmoStateUpdated, AddressOf engine_AffectivEmoStateUpdated
AddHandler engine.EmoEngineEmoStateUpdated, AddressOf engine_EmoEngineEmoStateUpdated
AddHandler engine.CognitivTrainingStarted, AddressOf engine_CognitivTrainingStarted
AddHandler engine.CognitivTrainingSucceeded, AddressOf engine_CognitivTrainingSucceeded
AddHandler engine.CognitivTrainingCompleted, AddressOf engine_CognitivTrainingCompleted
AddHandler engine.CognitivTrainingRejected, AddressOf engine_CognitivTrainingRejected
AddHandler engine.ExpressivTrainingStarted, AddressOf engine_ExpressivTrainingStarted
AddHandler engine.ExpressivTrainingSucceeded, AddressOf engine_ExpressivTrainingSucceeded
AddHandler engine.ExpressivTrainingCompleted, AddressOf engine_ExpressivTrainingCompleted
AddHandler engine.ExpressivTrainingRejected, AddressOf engine_ExpressivTrainingRejected

Open in new window

0
 
LVL 1

Author Comment

by:Chris Jones
ID: 39963732
thanks let me try this i seen some examples online when i was researching the issue but could not pinpoint the syntax.
0
 
LVL 1

Author Comment

by:Chris Jones
ID: 39963894
real quick i was converting these functions as well but i tried the addhandler and it still did not work

            Private Sub Train1(sender As Object, e As Emotiv.EmoEngineEventArgs)
                theEmotivPower.m_EmoEngine.CognitivTrainingStarted -= started
                [stop] = New Emotiv.EmoEngine.CognitivTrainingSucceededEventHandler(AddressOf Train2)
                theEmotivPower.m_EmoEngine.CognitivTrainingSucceeded += [stop]
            End Sub
            Private Sub Train2(sender As Object, e As Emotiv.EmoEngineEventArgs)
                theEmotivPower.m_EmoEngine.CognitivTrainingSucceeded -= [stop]
                Semaphore_BlockTraining.Release()
            End Sub

Open in new window


erorr or on these lines

   theEmotivPower.m_EmoEngine.CognitivTrainingSucceeded -= [stop]
     theEmotivPower.m_EmoEngine.CognitivTrainingStarted -= started
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 2000 total points
ID: 39963896
You need RemoveHandler for those ones, rather than AddHandler since you are unregistering the event.
0
 
LVL 1

Author Comment

by:Chris Jones
ID: 39963902
ok cool i am slowly understanding it and now the  -= [stop] at the end
0
 
LVL 1

Author Comment

by:Chris Jones
ID: 39963903
never mind i see what is needed
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question