Solved

Error with converted c# code

Posted on 2014-03-29
7
54 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 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
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Suggested Solutions

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

738 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