Oh, I have it now
just declare a public variable name message or property in HellowWorldAdapter
In outside class, after start server, just assign this public this message and call HelloWorldAdapter. Run()
It will automatically publish your message
Following is my code:
1.Code for Start server:
Code:
        static DataProviderServer server;
        static TcpClient reqrepSocket;
        static TcpClient notifSocket;
        static HelloWorldAdapter adapter;

   private static void StartServer()
        {
            string host = "localhost";
            int reqrepPort = 6661;
            int notifPort = 6662;

            try
            {
                adapter = new HelloWorldAdapter();
                server = new DataProviderServer();
                server.Adapter = adapter;
                reqrepSocket = new TcpClient(host, reqrepPort);
                server.RequestStream = reqrepSocket.GetStream();
                server.ReplyStream = reqrepSocket.GetStream();
                notifSocket = new TcpClient(host, notifPort);
                server.NotifyStream = notifSocket.GetStream();
                server.Start();
                System.Console.WriteLine("Remote Adapter connected to Lightstreamer Server.");
                System.Console.WriteLine("Ready to publish data...");
            }
            catch (Exception e)
            {
                System.Console.WriteLine("Could not connect to Lightstreamer Server.");
                System.Console.WriteLine("Make sure Lightstreamer Server is started before this Adapter.");
                System.Console.WriteLine(e);
            }
        }
When sending message, just call this and give message as parameter:
Code:
private static void SendToClient(string message)
        {
            adapter.instantMessage = message;
            adapter.Run();
        }
And the rest is my HelloWorldAdapter:
Code:
using System;
using System.Collections;
using System.Threading;
using Lightstreamer.Interfaces.Data;

public class HelloWorldAdapter : IDataProvider
{
    private IItemEventListener _listener;
    private volatile bool go;
    public string instantMessage = "";
    public void Init(IDictionary parameters, string configFile)
    {
    }

    public bool IsSnapshotAvailable(string itemName)
    {
        return false;
    }

    public void SetListener(IItemEventListener eventListener)
    {
        _listener = eventListener;
    }

    public void Subscribe(string itemName)
    {
        if (itemName.Equals("greetings"))
        {
            Thread t = new Thread(new ThreadStart(Run));
            t.Start();
        }
    }

    public void Unsubscribe(string itemName)
    {
        if (itemName.Equals("greetings"))
        {
            go = false;
        }
    }

    public void Run()
    {
        Random rand = new Random();
        IDictionary eventData = new Hashtable();
        eventData["message"] = instantMessage;
        _listener.Update("greetings", eventData, false);
        Thread.Sleep(1000 + rand.Next(2000));
    }
}