1

I want to call Winform method from Windows Service.

For Example, Here is my Winform application code (MyWinForm),

public void TestMethod(){
     MessageBox.Show("Hello World!");
}

And here is my Windows Service (MyService),

protected override void OnStart(string[] args){
     MyWinform myWinform = new MyWinform();
     myWinform.TestMethod();
}

Please let me know if there is any other way to do this. Thank you.

Maari
  • 51
  • 7
  • 3
    If the purpose is to show some UI (like in your example), then this is not possible as Windows Service is a non-ui background task. – Hayden Apr 12 '21 at 04:31
  • Yeah I agree with your point but Winform supports ui right... And thank you so much for your response :) – Maari Apr 12 '21 at 06:02

1 Answers1

0

You can access winform methods from windows service by using name space System.Windows.Forms How ever as hayden said you can not access UI from windows servcie application

Ijas
  • 367
  • 1
  • 3
  • 18