我看到一些关于设计自定义等待类型的文章:
http://books.google.com.br/books?id=1On1glEbTfIC&pg=PA83&lpg=PA83&dq=create+a+custom+awaitable+type
现在考虑以下示例:
<Button x:Name="BtnA"
Width="75"
Margin="171,128,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Click="BtnA_Click"
Content="Button A" />
<Button x:Name="BtnB"
Width="75"
Margin="273,128,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Content="Button B" Click="BtnB_OnClick" />
Run Code Online (Sandbox Code Playgroud)
和:
private async void BtnA_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("Awaiting Button B..");
var sx = Observable.FromEvent<MouseButtonEventHandler,
MouseButtonEventArgs>(a => (b, c) => a(c),
add => BtnB.PreviewMouseDown += add,
rem => BtnB.PreviewMouseDown -= rem)
.Do(a => a.Handled = true)
.Take(1);
await sx;
MessageBox.Show("Button B Pressed after Button A");
}
private void BtnB_OnClick(object sender, RoutedEventArgs e)
{
MessageBox.Show("Button B Pressed …Run Code Online (Sandbox Code Playgroud) 假设我使用新的DepencyInjection框架在新的ASP.Net/vNext中配置我的类和依赖项.
我该如何使用,如何获取预定义的配置设置?
public void ConfigureServices(IServiceCollection services)
{
// Add Application settings to the services container.
services.Configure<AppSettings>(Configuration.GetSubKey("AppSettings"));
// Add EF services to the services container.
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));
// Add Identity services to the services container.
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
// Configure the options for the authentication middleware.
// You can add options for Google, Twitter and other middleware as shown below.
// For more information see http://go.microsoft.com/fwlink/?LinkID=532715
services.Configure<FacebookAuthenticationOptions>(options =>
{
options.AppId = Configuration["Authentication:Facebook:AppId"];
options.AppSecret = Configuration["Authentication:Facebook:AppSecret"];
});
services.Configure<MicrosoftAccountAuthenticationOptions>(options …Run Code Online (Sandbox Code Playgroud) 考虑到所有应用程序都将与Web项目(将使用云或Web服务)进行交互这一事实.有没有办法在应用程序之间共享我的类模型?
如果是的话,最好的方法是什么?
关于从Webservice发送/接收数据,序列化和反序列化,如何以简单的方式执行此操作而无需手动填充对象?
有关此应用程序的任何信息都非常有用!
将令牌放在任务的构造函数中的原因很多,如下所述: 任务构造器中的取消令牌:为什么?
通过使用关键字async / await,它如何工作?例如下面的代码:
public async Task MethodAsync(CancellationToken token)
{
await Method01Async();
await Method02Async();
}
Run Code Online (Sandbox Code Playgroud)
虽然这是一个异步过程。我很快就使用了“ Task.StartNext”或“ Task.Run”或“新任务”。为了能够指定我的取消令牌,该怎么办?
有什么区别和对代码的影响?
性能和限制如何,哪种更适合?
新属性:
- [CallerFilePathAttribute]
- [CallerMemberName]
- [CallerLineNumber]
今天它们也可以在.NET 4中使用(它易于开发并且看起来很神奇).它们的值在运行时被编译或解析?
我无法在ContentPresenter(NormalTextDay)中创建动画或自定义颜色,此错误出现在我的XAML中:
'System.Windows.Media.Animation.ColorAnimation'动画对象不能用于动画属性'Foreground'它是因为不兼容的类型'System.Windows.Media.Brush
<Style x:Key="CalendarDayButtonStyle" TargetType="{x:Type CalendarDayButton}">
<Setter Property="MinWidth" Value="5"/>
<Setter Property="MinHeight" Value="5"/>
<Setter Property="FontSize" Value="10"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type CalendarDayButton}">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="0:0:0.1"/>
</VisualStateGroup.Transitions>
<VisualState x:Name="Normal"/>
<VisualState x:Name="MouseOver">
<Storyboard>
<DoubleAnimation Duration="0" To="0.5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="HighlightBackground"/>
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<DoubleAnimation Duration="0" To="0.5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="HighlightBackground"/>
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled">
<!--<Storyboard>
<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="HighlightBackground"/>
<DoubleAnimation Duration="0" To=".35" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="NormalText"/>
</Storyboard>-->
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="SelectionStates">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="0"/>
</VisualStateGroup.Transitions>
<VisualState …Run Code Online (Sandbox Code Playgroud) 目前拥有.net 3.5和.net 4.0的一些项目.
决定将所有迁移到.NET 4.5.
所有项目都已在VS2012(C#5.0)中,所有项目都使用async-await关键字
正在使用.net 4.0项目正在使用Microsoft.Bcl.Async
On .net 3.5项目正在使用AsyncBridge.Net35和TaskParallelLibrary
问题是:
- .net 4.5中没有TaskEx类和其他扩展方法,或者我不知道这些是否存在
如何在不对代码进行重大更改的情况下进行此更改?
目前我使用了以下代码,它工作正常,但不尊重宽高比:
private double angle;
private Point transformOrigin;
private ContentControl designerItem;
public ResizeThumb()
{
DragStarted += new DragStartedEventHandler(this.ResizeThumb_DragStarted);
DragDelta += new DragDeltaEventHandler(this.ResizeThumb_DragDelta);
}
private void ResizeThumb_DragStarted(object sender, DragStartedEventArgs e)
{
this.designerItem = DataContext as ContentControl;
if (this.designerItem != null)
{
this.transformOrigin = this.designerItem.RenderTransformOrigin;
RotateTransform rotateTransform = this.designerItem.RenderTransform as RotateTransform;
if (rotateTransform != null)
this.angle = rotateTransform.Angle * Math.PI / 180.0;
else
this.angle = 0;
}
}
private void ResizeThumb_DragDelta(object sender, DragDeltaEventArgs e)
{
if (this.designerItem != null)
{
double deltaVertical, deltaHorizontal; …Run Code Online (Sandbox Code Playgroud) 样品:
var aux = new int[] { -1,0,1,-1,2,3,4,5,6,7 }
Run Code Online (Sandbox Code Playgroud)
预期结果:
{ 2,3,4,5,6,7,1,0,-1,-1 }
Run Code Online (Sandbox Code Playgroud)
怎么样?
-
编辑:抱歉这个糟糕的问题.我想从值2和其他放在较低端的人(我修复文本)中订购所有.
c# ×8
.net ×4
async-await ×3
wpf ×3
animation ×1
appsettings ×1
asp.net ×1
async-ctp ×1
colors ×1
controls ×1
linq ×1
reflection ×1
sorting ×1
sql-order-by ×1
transform ×1
visualstates ×1