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".
最近我发现这种语法适用于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"有效?有自动转换吗?
我正在尝试使用 TImage 以 Firemonkey HD 格式显示动画 GIF,但我没有看到任何动画方法。
使用 Vcl.Imaging.gifImg 不是一种选择,因为类型不同。
有人可以建议一种方法来解决这个问题,或者可能是在 Firemonkey 下为 GIF 图像设置动画的组件吗?
我现在找到的唯一方法是:
创建 TGIFImage 实例并加载 GIF 图片
循环遍历 gif.images:
一种。将当前图像保存到流
湾 Image1.bitmap.loadFromStream [Image1 是 FMX:TImage]
有没有更聪明的解决方案?
我有一个TGridLayout在Firemonkey HD应用程序中填充了一些图像.在gridLayout的onMouseDown事件中,我想获取用户点击的图像对象,但我只有鼠标坐标.
为每个图像实现onMouseDown事件不是一种选择,因为如果从gridlayout中删除图像,则会留下空白空间.在这种情况下,我还想知道用户是否已经点击了这个空白区域.
是否有某种"getChildAtPos"或"FindVCLWindow"模拟在Firemonkey?
谢谢!
在我的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) delphi ×3
firemonkey ×2
animated-gif ×1
arrays ×1
c# ×1
childcontrol ×1
delphi-xe2 ×1
delphi-xe7 ×1
ef-core-2.0 ×1
function ×1
gif ×1
javascript ×1
mousedown ×1
parallel-for ×1
pipeline ×1
powershell ×1