Adding a Service

Old forums and posts related to unsupported version of Syn Virtual Assistant.

Adding a Service

Postby Leslie » Thu Oct 02, 2014 6:27 pm

Syn Engine 2.0 has 3 types of services that can be used to run functions in the background without affecting the Virtual Assistants normal performance.

A Service is called every 1 second or more ( depending on the time taken to execute other services and the service speed set by the user ). Care should be taken since a service is called every 1 second some commands are only executed once using a Flag variable.

Services are usually executed inside a Mutli-Threaded environment so if your service is going to access any Forms/Controls make sure you use InvokeRequired method.

CSharp Code

using Syn.Engine;
namespace MyPlugin
public class MyPlugin : SynPlugin
public override void Initialize()
SynService myService = new SynService(() => MyService(), "My Service",10);
myService.Description = "My Service Tutorial";

int index = 0;

public SynResponse MyService()
SynResponse response = new SynResponse();
response.Message = "Service Call " + index.ToString();
return response;

Visual Basic Code

Imports Syn.Engine

Public Class MyPlugin
Inherits SynPlugin

Public Overrides Sub Initialize()
Dim Service As SynService = New SynService(Function() MyService(), "My Service", 10)
Service.Description = "My Service Tutorial"
End Sub

Dim index As Integer = 0

Public Function MyService() As SynResponse
Dim response As SynResponse = New SynResponse()
response.Message = "Service Call " + index.ToString()
index = index + 1
Return response
End Function

End Class

In the above example MyService is the service function that will be checked every 1 second. The service Function will only be executed once every 10 seconds. As you may have already noted the value "10" in the code above.

The output of this sample service is a message Service Call 1 ,Service Call 2 and so on.
User avatar
Lead Software Architect
Posts: 287
Joined: Fri Sep 14, 2012 12:20 pm

Return to Archived (Old Posts)

Who is online

Users browsing this forum: No registered users and 1 guest