Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Error with converted c# code

Posted on 2014-03-29
7
Medium Priority
?
60 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 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
Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

 
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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

670 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