小编iPa*_*h ツ的帖子

在TParallel.For中AStride是什么意思?

TParallel.For()有一个称为的论点AStride.在我的情况下,AStride是2:

  TParallel.&For(2, 1, 10,
    procedure(index: Integer)
    begin
      TThread.Queue(nil,
        procedure
        begin
          memo1.Lines.Add(index.ToString());
        end
      );
    end
  );
Run Code Online (Sandbox Code Playgroud)

我在这里无法理解"AStride"的技术含义.是否AStride = 2意味着第一个线程将处理该范围内的两个连续数字[1..10],第二个线程将处理下一个连续数字等?

**英语不是我的母语,我将"Stride"翻译为"long step"或"pace".

delphi multithreading parallel-for delphi-xe7

11
推荐指数
1
解决办法
801
查看次数

函数定义中使用的命名数组元素

最近我发现这种语法适用于JavaScript(Chrome 53):

function foo([param1]) { // Function argument is declared as array and param1 is used as variable? What is the name of this syntax?
  console.log(param1); 
}

foo(['TestParameter1']); // Case 1 - works. Output: TestParameter1
foo('TestParameter1');   // Case 2 - works??? Why? Output: TestParameter1
foo(123);                // Case 3 - does not work - VM860:1 Uncaught TypeError: undefined is not a function(…)

Result => TestParameter1 // this is the result
Run Code Online (Sandbox Code Playgroud)

我看到param1可以用作引用第一个参数中索引为0的项的变量(声明为数组).

我的问题是:

1)这个语法是如何命名的([param1]部分允许你使用param1作为变量)?

2)为什么"案例2"有效?有自动转换吗?

javascript arrays function implicit-conversion

6
推荐指数
1
解决办法
65
查看次数

Firemonkey 中的动画 GIF

我正在尝试使用 TImage 以 Firemonkey HD 格式显示动画 GIF,但我没有看到任何动画方法。

使用 Vcl.Imaging.gifImg 不是一种选择,因为类型不同。

有人可以建议一种方法来解决这个问题,或者可能是在 Firemonkey 下为 GIF 图像设置动画的组件吗?

我现在找到的唯一方法是:

  1. 创建 TGIFImage 实例并加载 GIF 图片

  2. 循环遍历 gif.images:

    一种。将当前图像保存到流

    湾 Image1.bitmap.loadFromStream [Image1 是 FMX:TImage]

有没有更聪明的解决方案?

delphi gif animated-gif delphi-xe2 firemonkey

5
推荐指数
1
解决办法
7282
查看次数

管道中的cmdlet是并行执行的吗?

我在"专业人士的PowerShell笔记"白皮书中发现了一个有趣的声明 - "在管道系列中,每个函数都与其他函数并行运行,如并行线程":

在此输入图像描述

那是对的吗?如果"是",是否有支持此声明的技术文档?

parallel-processing powershell pipeline

5
推荐指数
1
解决办法
609
查看次数

如何在onMouseDown事件中获取鼠标光标下的控件?

我有一个TGridLayout在Firemonkey HD应用程序中填充了一些图像.在gridLayout的onMouseDown事件中,我想获取用户点击的图像对象,但我只有鼠标坐标.

为每个图像实现onMouseDown事件不是一种选择,因为如果从gridlayout中删除图像,则会留下空白空间.在这种情况下,我还想知道用户是否已经点击了这个空白区域.

是否有某种"getChildAtPos"或"FindVCLWindow"模拟在Firemonkey

谢谢!

delphi childcontrol mouse-position mousedown firemonkey

4
推荐指数
1
解决办法
3331
查看次数

GetEntityTypes:使用EF Core中的.Property <TEntity>的通用版本配置实体属性

在我的EF核心项目中,我有一些从基类DBEntity继承的实体:

public abstract class DBEntity
{
    public int Id { get; set; }

    public DateTime CreatedOn { get; set; }

    public DateTime UpdatedOn { get; set; }

    public EntityStatus EntityStatus { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我想为从DBEntity继承的每个实体设置一些具有默认值的特定属性.目前我正在使用此代码:

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {

        var entities = modelBuilder.Model
            .GetEntityTypes()
            .Where(w => w.ClrType.IsSubclassOf(typeof(DBEntity)))
            .Select(p => modelBuilder.Entity(p.ClrType));

        foreach (var entity in entities)
        {

            entity
                .Property("CreatedOn")
                .HasDefaultValueSql("GETDATE()");

            entity
                .Property("UpdatedOn")
                .HasComputedColumnSql("GETDATE()");

            entity
                .Property("EntityStatus")
                .HasDefaultValue(EntityStatus.Created);

        }
    }
Run Code Online (Sandbox Code Playgroud)

这工作正常,但我不想使用字符串常量指定属性名称(对于重构等不好).

有没有办法循环从DBEntity继承的实体并使用属性表达式配置默认值,如下所示:

foreach (var entity in entities)
{
    entity
      .Property(k …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework entity-framework-core ef-core-2.0

3
推荐指数
1
解决办法
684
查看次数