我有这个代码重新启动服务,但这不起作用.
我可以单独启动和停止但不重启,这涉及到我首先停止并启动服务.
try
{
//service.Stop();
//service.Start();
int millisec1 = Environment.TickCount;
TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds);
service.Stop();
service.WaitForStatus(ServiceControllerStatus.Stopped, timeout);
// count the rest of the timeout
int millisec2 = Environment.TickCount;
timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds - (millisec2 - millisec1));
service.Start();
service.WaitForStatus(ServiceControllerStatus.Running, timeout);
}
catch
{
// ...
}
Run Code Online (Sandbox Code Playgroud)
它只是进入捕获部分.
我不知道我哪里错了.
有什么建议.??
更新:
所以我从下面的正确答案中得出了这个想法:
这是需要做的事情>
public static void RestartService(string serviceName, int timeoutMilliseconds)
{
ServiceController service = new ServiceController(serviceName);
int millisec1 = Environment.TickCount;
TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds);
if (!(service.Status.Equals(ServiceControllerStatus.Stopped) || service.Status.Equals(ServiceControllerStatus.StopPending)))
{
service.Stop();
service.WaitForStatus(ServiceControllerStatus.Stopped, timeout);
} …Run Code Online (Sandbox Code Playgroud) 如果我想在drupal系统之外的php文件中使用全局$ user,那么我必须使用drupal_boostrap()进入boostrap的距离.我不想使用DRUPAL_BOOTSTRAP_FULL,因为它设置了HTTP标头.
我知道使用线程比使用c#DoEvents()更有效,但我仍然想知道java中是否存在等效函数.我用Google搜索,但我找不到任何东西.
我正在学习boost/asio并编写电子书中的示例程序.当然它没有用;)
#include <boost/asio.hpp>
#include <iostream>
int main () {
boost::asio::io_service io_service;
boost::asio::ip::tcp::resolver::query query("www.boost.org", "http");
boost::asio::ip::tcp::resolver::iterator destination = boost::asio::ip::tcp::resolver::resolve(query); // if i have "." before "resolve" as in books example compilers says i need primary-expresion.
boost::asio::ip::tcp::endpoint endpoint;
while ( destination != end ) {
endpoint = *destination++;
std::cout<<endpoint<<std::endl;
}
boost::asio::ip::tcp::socket socket(io_service);
socket.connect(endpoint);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
在"resolve"之前用"::"编译输出:
/home/martins/C++/boost_asio_client/client.cpp|7|error: cannot call member function
‘boost::asio::ip::basic_resolver<InternetProtocol, ResolverService>::iterator
boost::asio::ip::basic_resolver<InternetProtocol,
ResolverService>::resolve(boost::asio::ip::basic_resolver<InternetProtocol,
ResolverService>::query&)
[with InternetProtocol = boost::asio::ip::tcp, ResolverService =
boost::asio::ip::resolver_service<boost::asio::ip::tcp>,
boost::asio::ip::basic_resolver<InternetProtocol, ResolverService>::iterator =
boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>,
boost::asio::ip::basic_resolver<InternetProtocol, ResolverService>::query =
boost::asio::ip::basic_resolver_query<boost::asio::ip::tcp>]’ …Run Code Online (Sandbox Code Playgroud) 我有一个非常奇怪的错误,在Visual Studio 2010中似乎是一个怪癖:有时,当将光标移动到CSS style=""属性的双引号时,光标拒绝移动.我无法输入任何内容,响应的键是UP/ DOWN光标键和DEL键(但不是BACKSPACE).
键入不执行任何操作,但按下LEFT/ RIGHT打开光标键会产生以下错误:
操作无法完成
我不知道造成这种情况的原因是什么,但我猜测Intellisense会变得非常困惑并且不知所措.
此刻,每当发生这种情况时,我必须在style属性的双引号中写出任何CSS outsite,然后将光标放在我希望CSS出现的地方(使用鼠标)并按CTRL- V将其粘贴进去.非常讨厌: (
必须有办法解决这个问题......?
希望有人有答案!
我开始使用python中的多线程(或者至少我的脚本可能会创建多个线程).这个算法是否是Mutex的正确用法?我还没有测试过这段代码,它甚至可能都无法运行.我只是希望processData在一个线程中运行(一次一个)并且主while循环继续运行,即使队列中有一个线程.
from threading import Thread
from win32event import CreateMutex
mutex = CreateMutex(None, False, "My Crazy Mutex")
while(1)
t = Thread(target=self.processData, args=(some_data,))
t.start()
mutex.lock()
def processData(self, data)
while(1)
if mutex.test() == False:
do some stuff
break
Run Code Online (Sandbox Code Playgroud)
编辑:重新阅读我的代码我可以看到它是非常错误的.但是,嘿,这就是我在这里寻求帮助的原因.
在我的应用程序中,有一些特定于应用程序的设置,下次我的应用程序启动时应该可以使用.
换句话说,我希望数据在应用程序周期的会话中可用.
这可以在不使用数据库(sqlite)的情况下实现.
如果浏览器不是IE,我怎么才能加载css文件?
换句话说,我想加载一个css文件,只有它是Safari,Firefox o Chrome.与此相反:
<!--[if IE 8]>
<![endif]-->
Run Code Online (Sandbox Code Playgroud)
谢谢
我有一个带有DataTrigger设置的DataGrid,所以当它的值为"UP"时,我希望触发器只改变'directionColumn'datagridcolumn中的背景.
到目前为止,我已经更新了整行.我也尝试在setter元素中放置'targetname',但这只是一个错误.请帮忙.
XAML:
<DataGrid AutoGenerateColumns="False" ItemsSource="{Binding}" Name="summaryReportDataGridDATE" RowDetailsVisibilityMode="VisibleWhenSelected" Width="330">
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Direction}" Value="UP">
<Setter>
<Setter.Property>Background</Setter.Property>
<Setter.Value>Red</Setter.Value>
<!--<Setter Property="Background" Value="Red" TargetName="directionColumn"/>-->
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.CellStyle>
<DataGrid.Columns>
<!--<DataGridTemplateColumn x:Name="dateColumn" Header="Date" Width="100" CanUserReorder="False" CanUserSort="False" FontFamily="Arial Rounded MT" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<DatePicker SelectedDate="{Binding Path=Date, Mode=OneWay}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>-->
<DataGridTextColumn x:Name="dateColumn" Binding="{Binding Path=Date, StringFormat={}{0:dd/MM/yyyy}}" Header="Date" Width="80" CanUserReorder="False" CanUserSort="False" FontFamily="Arial Rounded MT"/>
<DataGridTextColumn x:Name="closeColumn" Binding="{Binding Path=ClosingPrice}" Header="ClosingPrice" Width="80" CanUserReorder="False" CanUserSort="False" FontFamily="Arial Rounded MT" />
<DataGridTextColumn x:Name="directionColumn" Binding="{Binding Path=Direction}" Header="Direction" Width="80" …Run Code Online (Sandbox Code Playgroud) 如何评论此枚举,以便不显示警告?是的我意识到评论是不必要的,但如果评论很容易并且它解决了警告,那么我想这样做.
出现的警告:缺少公开可见类型或成员的XML注释
/// <summary>
/// Conditional statements
/// </summary>
public enum ConditionType
{
Equal,
NotEqual,
GreaterThan,
GreaterThanOrEqual,
LessThan,
LessThanOrEqual
}
Run Code Online (Sandbox Code Playgroud) c# ×2
css ×2
android ×1
boost-asio ×1
c++ ×1
comments ×1
datagrid ×1
datatrigger ×1
drupal ×1
drupal-6 ×1
enums ×1
html ×1
intellisense ×1
java ×1
mutex ×1
persistence ×1
python ×1
swing ×1
wpf ×1
xaml ×1