我正在尝试构建一个使用VS2017创建的简单C#7类库项目.
框架程序集中的MSBuild已过时,所以我正在引用Microsoft.Build,Microsoft.Build.Engine并Microsoft.Build.Framework从visual studio(C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin)中的MSBuild文件夹中引用.
不过,当我这样做时:
using (var collection = new ProjectCollection())
{
var proj = collection.LoadProject(@"c:\projects\Sample\Sample.csproj"); // <-- exception
proj.Build(new[] {new ConsoleLogger()});
}
Run Code Online (Sandbox Code Playgroud)
我越来越 InvalidProjectFileException: The tools version "15.0" is unrecognized. Available tools versions are "4.0", "2.0".
是否有使用最新构建工具和C#7编译器调用构建的编程方法?
我需要能够让用户在我的fullcalendar上移动一些事件.我想去服务器并获取交易对手的忙碌时间,并在拖动进行时将它们显示为日历上的背景事件.但是,当我在拖动过程中调用.fullcalendar('renderEvents',[...])时,fullcalendar中的拖动机制会中断并停止.
有没有办法在不破坏拖动的情况下添加事件或以其他方式突出显示必须使用ajax调用检索的繁忙时间?
示例如下:https://jsbin.com/qikiganelu/1/edit?js,output.尝试拖动"与Bob会面".
$(function() { // document ready
$('#calendar').fullCalendar({
header: {
left: '',
center: '',
right: ''
},
defaultView: 'agenda',
duration: {days: 2},
allDaySlot: false,
defaultDate: '2017-04-27',
minTime: '9:00',
maxTime: '17:00',
events: [
{
title: 'Keynote',
start: '2017-04-27T09:00',
end: '2017-04-27T11:00',
editable: false,
color: "gray",
},
{
title: 'Meeting with Bob',
start: '2017-04-27T12:30',
end: '2017-04-27T13:00',
editable: true,
},
],
eventDragStart: function(event, jsEvent, ui, view){
// fetch Bob's busy times and add them as background events
var busyTimes …Run Code Online (Sandbox Code Playgroud)我创建自己的FrameworkElement并覆盖VisualChildrenCount{get;}并GetVisualChild(int index)返回我自己的DrawingVisual实例.
如果我在初始渲染后(例如在计时器处理程序中)使用DrawingVisual.RenderOpen()和绘制到上下文中修改视觉内容,则不刷新元素.
这是最简单的样本:
using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Threading;
namespace VisualTest
{
public class TestControl : FrameworkElement
{
private readonly DrawingVisual _visual = new DrawingVisual();
public TestControl()
{
Draw(false);
var timer = new DispatcherTimer {Interval = new TimeSpan(0, 0, 2)};
timer.Tick += (sender, args) =>
{
Draw(true);
InvalidateVisual();
timer.Stop();
};
timer.Start();
}
protected override Visual GetVisualChild(int index)
{
return _visual;
}
protected override int VisualChildrenCount
{
get …Run Code Online (Sandbox Code Playgroud) 我需要一种同步执行某些操作的方法,该操作应在半秒内完成,但可能只会停留几分钟。如果超时我不在乎结果。这是我现在正在使用编译器生成的 delegate.BeginInvoke 执行的操作:
static void Main()
{
bool disposed = false;
var wait = new ManualResetEvent(false);
var a = new Action(
() =>
{
Thread.Sleep(1000); // <- some looong action
if (!disposed)
lock (wait)
if (!disposed)
wait.Set();
});
a.BeginInvoke(a.EndInvoke, null);
bool success = wait.WaitOne(500);
Console.WriteLine(success ? "success" : "timeout");
lock (wait)
{
wait.Dispose();
disposed = true;
}
Console.ReadLine();
}
Run Code Online (Sandbox Code Playgroud)
看起来很丑。我知道 lambda 闭包的disposed变量已被修改(与我的 ReSharper 不同,我喜欢这个 C# 功能)。一切都是因为我想处置掉ManualResetEvent。您能建议 .NET4 中更好的方法吗?也许我应该跳过处理事件并依赖 GC?
需要注意的是:ManualResetEvent.Set()如果您尝试在已处置的实例上执行此操作,则会爆炸。
c# ×2
begininvoke ×1
c#-7.0 ×1
fullcalendar ×1
javascript ×1
jquery ×1
msbuild ×1
rendering ×1
synchronous ×1
threadpool ×1
timeout ×1
wpf ×1