根据需要使用IntentService背景MediaPlayer播放是否合理?根据开发人员指南,IntentService只有在实际工作时才会持续.考虑到MediaPlayer每当我想再次播放曲目时重新初始化所产生的开销,这似乎是一个糟糕的想法......
所以我的问题是:使用这种方式实际产生的开销有多大Service.它会对系统/应用程序的性能产生可察觉的影响吗?我应该使用自己Service的专用工作线程实现吗?
当我想通过"Run As - > GWT application"在eclipse中编译我的GWT应用程序时,我得到以下消息:
00:00:00,005 [WARN]模块声明了一个servlet类'com.google.gwt.junit.server.JUnitHostImpl',但是web.xml没有相应的声明; 请在web.xml中添加以下行:
<servlet> <servlet-name>jUnitHostImpl</servlet-name> <servlet-class>com.google.gwt.junit.server.JUnitHostImpl</servlet-class> </servlet> <servlet-mapping> <servlet-name>jUnitHostImpl</servlet-name> <url-pattern>/AdminInterface/junithost/*</url-pattern> </servlet-mapping>
Run Code Online (Sandbox Code Playgroud)
当我将这些行添加到我的web.xml时,消息不再发生,但编译器似乎被冻结了.通常会在窗口顶部的"启动URL"处显示一个链接,这会将我引导到我的Web应用程序页面.但它一直说"计算",而且进程本身不使用任何CPU时间.
有谁知道如何解决这一问题?
我正在开发一个项目,它需要复制大量文件和目录,同时保留其原始时间戳.所以,我需要多次调用目标的SetCreationTime(),SetLastWriteTime()和SetLastAccessTime()方法,以原始值从源到目标的复制.如下面的屏幕截图所示,这些简单的操作占用了总计算时间的42%.

由于这极大地限制了我的整个应用程序的性能,我想加快速度.我假设,每个调用都需要打开和关闭文件/目录的新流.如果这就是原因,我想打开这个流,直到我写完所有属性.我该如何做到这一点?我想这需要使用一些P/Invoke.
更新:
我跟着卢卡斯建议使用WinAPI的方法CreateFile(..)用FILE_WRITE_ATTRIBUTES.为了P/Invoke我提到的以下包装方法:
public class Win32ApiWrapper
{
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern SafeFileHandle CreateFile(string lpFileName,
[MarshalAs(UnmanagedType.U4)] FileAccess dwDesiredAccess,
[MarshalAs(UnmanagedType.U4)] FileShare dwShareMode,
IntPtr lpSecurityAttributes,
[MarshalAs(UnmanagedType.U4)] FileMode dwCreationDisposition,
[MarshalAs(UnmanagedType.U4)] FileAttributes dwFlagsAndAttributes,
IntPtr hTemplateFile);
public static SafeFileHandle CreateFileGetHandle(string path, int fileAttributes)
{
return CreateFile(path,
(FileAccess)(EFileAccess.FILE_WRITE_ATTRIBUTES | EFileAccess.FILE_WRITE_DATA),
0,
IntPtr.Zero,
FileMode.Create,
(FileAttributes)fileAttributes,
IntPtr.Zero);
}
}
Run Code Online (Sandbox Code Playgroud)
我可以在这里找到我使用的枚举.这使我能够只打开文件一次完成所有事情:创建文件,应用所有属性,设置时间戳并从原始文件中复制实际内容.
FileInfo targetFile;
int fileAttributes;
IDictionary<string, long> timeStamps;
using …Run Code Online (Sandbox Code Playgroud) 我在python中实现了k-nearest-neighbours算法,以对mnist数据库中随机选择的图像进行分类。但是,我发现距离函数非常慢:将10个测试图像的analisys与10k图像的训练集进行对比大约需要2分钟。图像的分辨率为28x28像素。由于我是python的新手,所以我觉得这可能会更快。该函数应该用于计算两个相同大小的灰度图像之间的欧式距离。
def calculateDistance(image1, image2):
distance = 0
for i in range(len(image1)):
for j in range(len(image1)):
distance += math.pow((image1[i][j]-image2[i][j]),2)
distance = numpy.sqrt(distance)
return distance
Run Code Online (Sandbox Code Playgroud) 我想从我的项目的App.config文件中读取一些值,但是当我这样做时:
var appsettings = System.Configuration.ConfigurationManager.AppSettings;
Run Code Online (Sandbox Code Playgroud)
我只得到四项:StopTestRunCallTimeoutInSeconds,LogSizeLimitInMegs,CreateTraceListener和GetCollectorDataTimeout,其中甚至没有在XML列.我的钥匙username,password甚至没有出现.
我的App.Config看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<appSettings>
<add key="username" value="Administrator" />
<add key="password" value="password" />
</appSettings>
<system.web>
<membership defaultProvider="ClientAuthenticationMembershipProvider">
<providers>
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
</providers>
</membership>
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
<providers>
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
</providers>
</roleManager>
</system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我错过了什么吗?在我看来,我正在阅读一个完全不同的配置文件,但没有其他的.
我正在尝试读取组 groupType 属性的SECURITY_ENABLED标志。问题是我使用的价值
DirectoryEntry entry...
entry.Properties["groupType"].Value;
Run Code Online (Sandbox Code Playgroud)
是int32,其范围是-2,147,483,647 到 2,147,483,648(或 -0x7FFFFFFF 到 0x80000000)

因此,只要GROUP_TYPE_SECURITY_ENABLED设置了和任何其他仲裁标志,数值就会超出 int32 的范围,就会发生溢出。

有谁知道如何避免这种溢出以读取正确的值?
c# ldap integer-overflow active-directory active-directory-group