Solved

Error with converted c# code

Posted on 2014-03-29
7
51 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
7 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 500 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

813 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now