Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
Web service name is UF17DataDownloader, am start starting this by creating object
like
DataDownload = new UF17DataDownloader();
 
can any one tell me how to stop this service
Posted 28-Dec-12 22:26pm
Edited 28-Dec-12 22:37pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Well, on top of which framework does your srevice was built???
Please, clarify as much as possible in your question!
  Permalink  
Comments
   
Thanks for your reply.
am using Framework 3.5
 
protected void btnStartService_Click(object sender, EventArgs e)
{
if (btnStartService.Text == "Start Service")
{
DataDownload = new UF17DataDownloader();
btnStartService.Text = "Stop Service";
}
else
{
if (DataDownload != null)
DataDownload.Dispose();
btnStartService.Text = "Start Service";
}
}
 
i want to start and stop service by clicking on button
Oleksandr Kulchytskyi at 29-Dec-12 4:50am
   
Ok, where did you get this UF17DataDownloader?
This module was written by U?
   
one website i created, in that only that UF17DataDownloader Webservice also there,
that Web Service will act as TCPIP server to Download data from clients.
Webpage contains one Button to start and Stop Service.On button click i need stop this Service.
Oleksandr Kulchytskyi at 29-Dec-12 5:06am
   
Whithout any internals of UF17DataDownloader i can't advise you smth.
   
In UF17DataDownloader am using TCPListener to act as server,
whenever data received from client i will store in Text file.Am this and all in that Web services
Oleksandr Kulchytskyi at 29-Dec-12 5:26am
   
Ok, wait few minutes... and i will provide you with basic idea.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

class Server
  {
    private volatile bool _isStopRequested=false;
    private TcpListener tcpListener;
    private Thread listenThread;
 
    public Server()
    {
      this.tcpListener = new TcpListener(IPAddress.Any, 3000);
      this.listenThread = new Thread(new ThreadStart(ListenForClients));
    }
 
    public void Start()
    {
     this.listenThread.Start();
    }
 
public void Stop(){ 
_isStopRequested=false;
}
 

  private void ListenForClients()
  {
    this.tcpListener.Start();
 
    while (!_isStopRequested)
    {
      //blocks until a client has connected to the server
      TcpClient client = this.tcpListener.AcceptTcpClient();
 
      //do some stuff with your workflow....
    } 
  }
}
 
i think you will catch the basic idea of starting and stopping service.
  Permalink  
Comments
   
From this i got that i can start and stop the TCPIP server,
is it possible to stop Web service itself
Oleksandr Kulchytskyi at 29-Dec-12 5:57am
   
Well i completelly confused. as far as i understood UF17DataDownloader itself is your web service ?
As concerns real web-services in dot Net, where does you host it ? And which type of service WCF ?
If yes and it host in windows enviromnemnt , though:
 
host = new ServiceHost(serviceType);
host.Open(); //-- start WCF service;
 
//....
 
host.Close(); // -operation that stops WCF service.
 
In case os IIS hosting of web-service ... this won't work.,..
   
yes UF17DataDownloader is the Web service, now am just running it in visual studio 2008, it is not WCF Service and also not completely web sevice,
i created one web site in that i added Web service.In that website itself i want to start and stop web service,is it possible to do.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 623
1 George Jonsson 268
2 OriginalGriff 225
3 CPallini 220
4 PIEBALDconsult 155
0 OriginalGriff 5,865
1 Sergey Alexandrovich Kryukov 5,316
2 CPallini 4,760
3 George Jonsson 3,400
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 29 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100