异步任务(异步/等待)如何在.Net 4.5中运行?
一些示例代码:
private async Task<bool> TestFunction()
{
var x = await DoesSomethingExists();
var y = await DoesSomethingElseExists();
return y;
}
Run Code Online (Sandbox Code Playgroud)
第二个await陈述是立即执行还是在第一次await返回后执行?
在VS 2015下编译.Net Core RC2项目时,我收到以下错误
GETSDKTOOLINGINFO:错误:未安装.NET Core SDK或在路径C:\ Program Files\dotnet\bin下找不到.构建和运行此项目需要这些组件.
该目录下存在文件.
此外,当我将dotnet输入命令行时,我确实看到了它正确的版本号和东西.(.NET命令行工具(1.0.0-beta-001598)
知道如何解决这个问题吗?
我有TextBlock以下设置:
TextWrapping="Wrap"
Run Code Online (Sandbox Code Playgroud)
我可以确定最大行数吗?
例如,考虑以下字符串TextBlock.Text:
This is a very good horse under the blackboard!!
Run Code Online (Sandbox Code Playgroud)
它目前已经显示如下:
This is a very
good horse under
the blackboard!!
Run Code Online (Sandbox Code Playgroud)
我需要这样做:
This is a very
good horse ...
Run Code Online (Sandbox Code Playgroud)
任何解决方案
我在内存中生成了许多BufferedImages,我想将它们压缩成一个zip文件,然后再将其作为电子邮件附件发送.如何在不从磁盘读取文件的情况下将文件保存到zip文件中.
有没有办法在不创建临时文件的情况下压缩这些文件?
由于创建了数千个文件,因此写入磁盘非常耗时.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package cccprog;
import java.awt.Component;
import java.awt.Panel;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JRadioButton;
/**
*
* @author Z
*/
public class N {
public static void main(String[] args) throws Exception {
for (int i = 0; i < 10; i++) {
JFrame jf = new JFrame();
Panel a = new Panel();
JRadioButton birdButton …Run Code Online (Sandbox Code Playgroud) 我正在用c#开发一个WinRT应用程序,我使用GridView来呈现我的项目.
我希望我的项目水平排列然后(当达到最大宽度时)下一项应添加到新行(简单: 只能看到垂直滚动条).
不幸的是,我当前的xaml只能在一行中添加水平项目(带有水平滚动条)
<GridView x:Name="GridChildItem"
ItemContainerStyle="{StaticResource NonTickGridViewItem}"
VerticalContentAlignment="Stretch"
ItemTemplate="{StaticResource CustomChildItemTemplete}"
SelectionMode="Single"
IsItemClickEnabled="True"
ItemClick="gridViewChild_ItemClick_1"
Margin="0,40,0,0"
Height="Auto"
Background="{StaticResource DropDownMenuBackColor}"
ScrollViewer.IsHorizontalScrollChainingEnabled="False"
ScrollViewer.IsVerticalScrollChainingEnabled ="True"
VerticalAlignment="Top">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" Margin="20,0,0,0" />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</GridView>
Run Code Online (Sandbox Code Playgroud) 我的VS 2017在EventViewer中不断出现以下错误.知道它崩溃的原因吗?
Exception Info: System.InvalidOperationException
at System.Linq.Enumerable.Single[[System.Byte, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.Generic.IEnumerable`1<Byte>)
at System.Linq.ImmutableArrayExtensions.SingleOrDefault[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.Immutable.ImmutableArray`1<System.__Canon>, System.Func`2<System.__Canon,Boolean>)
at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioProjectTracker.GetOrCreateProjectFromArgumentsAndReferences(Microsoft.VisualStudio.LanguageServices.ProjectSystem.IWorkspaceProjectContextFactory, System.String, System.Collections.Generic.IReadOnlyDictionary`2<System.String,Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.DeferredProjectInformation>, System.Collections.Generic.IReadOnlyDictionary`2<System.String,System.String>)
at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioProjectTracker.GetOrCreateProjectFromArgumentsAndReferences(Microsoft.VisualStudio.LanguageServices.ProjectSystem.IWorkspaceProjectContextFactory, System.String, System.Collections.Generic.IReadOnlyDictionary`2<System.String,Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.DeferredProjectInformation>, System.Collections.Generic.IReadOnlyDictionary`2<System.String,System.String>)
at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioProjectTracker+<PopulateWorkspaceFromDeferredProjectInfoAsync>d__86.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioProjectTracker+<LoadSolutionFromMSBuildAsync>d__79.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
at Roslyn.Utilities.TaskExtensions+<FireAndForget>d__0.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0(System.Object)
at Microsoft.VisualStudio.Threading.JoinableTaskFactory+SingleExecuteProtector.TryExecute()
at Microsoft.VisualStudio.Threading.JoinableTaskFactory+SingleExecuteProtector+<>c.<.cctor>b__20_0(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, …Run Code Online (Sandbox Code Playgroud) 我有一个TabHost有两个tabs.我第一次切换到第二tab了onResume()我的第二个的方法tab's activity调用.然后我有一个AlertDialog显示,并在它消失之后'onResume()'方法没有被调用,但我真的等待它.我假设调用'AlertDialog'触发'onPause()'方法并且'onResume()'应该在实际显示'Activity'并准备好与用户交互之前调用.但是当我切换回第一个tab是另一个时,没有调用'onPause()' activity.
您能否建议为什么不调用'onPause()'和'onResume()'方法以及在显示'AlertDialog'或切换之间调用哪些方法tabs?
在Windows 8 app dev上创建实验室.我无法加载所需的所有图像.因此,为了共享部分使用共享图像,我需要检查图像文件是否可用.该项目是一个使用XAML和C#的Windows网格应用程序.过去我使用过
Using System.IO
... lost of code
privat void share()
....
if (File.exist(filename)
{
add file to share
}
Run Code Online (Sandbox Code Playgroud)
如果我在我的window8项目中尝试这个.找不到File类.
我搜索互联网但无法找到一个代码示例来检查C#中windowsstore应用程序的存在
米希尔
在尝试编译使用代码签名的ac#项目时,我在VS2015中遇到以下错误.我在VS2013中没有收到此错误.
此外,任何地方都没有关于此错误的信息.
是否可以将 InkCanvas 笔触集合保存到 svg 图像?我唯一能找到的是,我可以将笔画保存为带有嵌入式 ISF(墨水序列化格式)的 GIF,或者将它们呈现为位图。我想以可以与其他平台(如 Web)互操作的矢量格式保存笔画。