使用c#winforms app启动owin
创建了一个启动配置文件
private void StartServer()
{
try
{
SignalR = WebApp.Start(URL);
}
catch (TargetInvocationException)
{
//Todo
}
this.Invoke((Action) (() => richTextBox1.AppendText("Server running on " + URL)));
然后在我的窗体上:
private void StopServer()
{
try
{
//STOP!!
}
catch (TargetInvocationException)
{
}
}
如何停止\重新启动OWIN服务,例如会很棒?
foreach ($leggi['LeggeRegionale'] as $legge) {
echo $legge['intestazione'];
foreach ($legge['articolato'] as $key => $articolo) {
echo $articolo['num_articolo'];
echo $articolo['rubrica'];
if (is_array($articolo['commi'])) {
echo $articolo['commi']['num_comma'];
echo $articolo['commi']['alinea'];
echo $articolo['commi']['corpo'];
}
}
}
答案 0 :(得分:8)
WebApp.Start()应该返回一个可以容纳的IDisposable对象,并在以后要停止服务器时进行处置。您将要进行适当的安全检查/异常处理,但一个简单的例子是:
private IDisposable myServer;
public void Start() {
myServer = WebApp.Start(URL);
}
public void Stop() {
myServer.Dispose();
}