none
Synchronizing DataTable Between Wcf Server And WCF Client RRS feed

  • Question

  • How can i synchronize the datatable of a wcf service with windows form the scenario is as below

    I have created a wcf service which has A Datatable which has two columns Namely Time Passed And Name

    the time passed column is always updated by a stopwatch 

    now i want to access the datatble of the wcf so that it shows in the datagridview of the windows form.The wcf service is a self hosted service or console application.I now want to access the datatable of the wcf service so that it shows in the datagridview. I have tried using A function in an operationcontract() as below

    <OperationContract()>
    function WcfDt() As Datatable

    below is the code of the function in the service class

    Public Dtus As New DataTAble("test")
    
    public sub new()
    dtus.columns.add("00:00:00",you)
    dtus.columns.add("00:00:00",me)
    End Sub
    
    public
    function wcfDt() As DAtaTAble Implements IService.WcfDt
    return dtus
    End Function
    

    I have added a service reference to my windows form app and its working

    I have created a sub that is executed when form is loading the the datagridview datasource is the wcfDt() fucntion

    it shows successfully but the time in the time passed is not changing which means it retrieves the datatable once.

    So how can i bind the datagriview to the wcf datatable such that they synchronize

    i have tried to create a console app with a similar datatabale but not as a wcf service and then try to add it as a reference to my windows form. The console app will have a shared variable as below

    Public Dtus As New DataTAble("test")
    Public shared dt As Datatable=Dtus
    public sub new()
    dtus.columns.add("00:00:00",you)
    dtus.columns.add("00:00:00",me)
    End Sub

    but i was told that it wont work when trying to access the datatable of process from another process

    so how can i achieve this

    Tuesday, April 26, 2016 3:11 PM

Answers