问题摘要:我设法加快了图像的翻阅速度,从而大大提高了图像的翻译速度,这是以使用并发为代价的.现在我需要确保对竞争条件的并发性.我将依赖脚本轮询正常文件的状态为独立的,但随后决定命名管道会更好.管道以避免轮询并命名,因为我无法从打开它们的脚本中获取PID(这是我需要使用管道进行通信的那个).
因此,当上传图像时,客户端通过AJAX将POST发送到脚本,该脚本1)保存图像2)产生并行脚本(独立)以拇指图像,3)将关于图像的JSON返回给客户端.然后客户端立即请求翻译版本,我们希望在发送响应时有足够的时间准备.但是如果它没有准备好,Apache mod_rewrites指向第二个脚本(依赖)的路径,它等待拇指完成,然后返回图像数据.
我希望这是相当简单的,但是,在通过终端单独测试独立脚本时,我得到了这个:
$ php -f thumb.php -- img=3g1pad.jpg
successSegmentation fault
Run Code Online (Sandbox Code Playgroud)
来源在这里:http://codepad.org/JP9wkuba 我怀疑我得到了一个段错误,因为我制作的fifo仍然是开放的,现在是孤儿.但我需要它来依赖脚本才能看到,对吧?它不应该是非阻塞的吗?我想这是因为脚本的其余部分可以运行....但它无法完成?正如我在开始时想到的那样,这将是普通文件的工作,除非两者都打开我不想进行轮询.我想最多投票一次并完成它.我只需要民意调查并忽略丑陋吗?
使用:
我已经实现了这个答案,创建了我自己的CheckBox
类,完成了一个IsChecked
DependencyProperty
.该属性由IsChecked
WPF上的属性支持CheckBox
,或者如果它可以工作.工作意味着在切换复选框时会调用我的getter和setter.
如果我将我的属性重命名为IsChecked_temp
并修改XAML以匹配,它可以正常工作.我认为这是一个命名冲突,但为什么不ElementName
解决呢?我的最小测试用例如下.
编辑0:我忘了提,我没有错误或警告.
编辑1:这个答案最初被接受,因为它适用于测试用例,但它显然不是完整的答案.将它应用于我的项目(并将CheckBox
类重命名为ToggleBox
)会XamlParseException
在每次使用属性时产生:
无法在"ToggleBox"类型的"IsChecked"属性上设置"绑定".'绑定'只能在DependencyObject的DependencyProperty上设置.
我会试着让一个最小的测试用例来展示这个.
CheckBox.xaml
<UserControl x:Class="CheckBox_test.CheckBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="Self">
<StackPanel>
<CheckBox IsChecked="{Binding IsChecked, ElementName=Self}" />
</StackPanel>
</UserControl>
Run Code Online (Sandbox Code Playgroud)
CheckBox.xaml.cs
using System.Windows;
using System.Windows.Controls;
namespace CheckBox_test
{
public partial class CheckBox : UserControl
{
public static readonly DependencyProperty IsCheckedProperty = DependencyProperty.Register(
"IsChecked",
typeof(bool),
typeof(CheckBox),
new FrameworkPropertyMetadata(false,
FrameworkPropertyMetadataOptions.AffectsRender));
public …
Run Code Online (Sandbox Code Playgroud) 我试图在其继承树中的一个类的构造函数中发现一个对象的派生类最多的类.我现在已经花了几个小时在这上面,我不知道我怎么做,或者为什么它没有意义.它似乎很有道理,但却拒绝工作.我找到了很多关于RTTI的页面,并且基本上没有它们.在我的测试用例及其输出之后,我将继续解释.
来源:
#include <iostream>
#include <typeinfo>
#include <string>
class A
{
public:
A(std::string foo);
virtual void bar(A* a) = 0;
};
class B : public A
{
public:
B();
virtual void bar(A* a);
};
A::A(std::string foo)
{
std::cout << "type as passed to A constructor: " << foo << " (" << this << ")" << std::endl;
std::cout << "type as determined in A constructor: " << typeid(*this).name() << " (" << this << ")" << std::endl;
}
B::B() : …
Run Code Online (Sandbox Code Playgroud) 我在Windows 8上使用.Net 3.5,使用默认的Aero主题.
这应该是Scale Checkbox的答案,没有扩展内容,但它没有像我预期的那样容易.我试着:
我有一个UserControl与此资源:
<UserControl.Resources>
<ResourceDictionary>
<!-- ... -->
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../Resources/CheckBoxStyle.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
Run Code Online (Sandbox Code Playgroud)
Resources/CheckBoxStyle.xaml是这样的:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:primitives="clr-namespace:System.Windows.Controls.Primitives;assembly=PresentationFramework">
<Style TargetType="{x:Type CheckBox}">
<Style.Resources>
<Style TargetType="{x:Type BulletDecorator}">
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="2" ScaleY="2"/>
</Setter.Value>
</Setter>
</Style>
</Style.Resources>
</Style>
</ResourceDictionary>
Run Code Online (Sandbox Code Playgroud)
该primitives
命名空间是什么我看中需要知道BulletDecorator是什么情况.
根据这个答案,我在这里的"默认WPF主题"链接后面的.Net 3.5的Aero主题中找到了BulletDecorator.
我看到我的复选框大小没有区别.我不认为我从主题中抓取了错误的元素类型,但还有什么可能发生?
编辑1:
BulletDecorator无论如何都包含复选框的内容,所以我尝试删除了#3的要求.现在我有一个巨大的盒子和巨大的文字,并希望缩小文本.这是CheckBoxStyle.xaml:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:primitives="clr-namespace:System.Windows.Controls.Primitives;assembly=PresentationFramework">
<Style TargetType="{x:Type CheckBox}">
<Style.Resources>
<Style TargetType="{x:Type ContentControl}"> …
Run Code Online (Sandbox Code Playgroud) 我想PropertyChangedEventHandler
在我的解决方案中找到所有事件,然后找到添加到这些事件的所有侦听器.但我似乎无法获得事件列表.
这是正在分析的解决方案中的所有代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RoslynTarget
{
public class Example : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged = delegate { };
public void DoNothing() { }
}
}
Run Code Online (Sandbox Code Playgroud)
这是我分析它的代码.references.Count == 1
而且r.Locations.Count == 0
,应该找到一个位置.这里发生了什么?
Program.cs中
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.FindSymbols;
using Microsoft.CodeAnalysis.MSBuild;
namespace RoslynTest
{
class Program
{
static void Main(string[] args)
{
const string solutionPath = @"C:\Users\<user>\Code\RoslynTarget\RoslynTarget.sln"; …
Run Code Online (Sandbox Code Playgroud)