none
这段代码应该如何改造为.net 4.0能兼容的代码 RRS feed

  • 问题

  • 下面代码是4.5的, task.run在4.0中编译不能通过.

    请问应该如何改造使其能支持4.0.

    另外, () =>{...}这是什么用法,哪里有详细介绍.

    谢谢.

    public Task<Bitmap> MakeHeatMap()
            {
              
                return Task.Run(() =>
                {
                    var result = new Bitmap(this.Width, this.Height, PixelFormat.Format32bppArgb);

                    this.GrayMap = this.makeGrayMap().Result; //*****

                    for (int x = 0; x < this.Width; x++)
                    {
                        for (int y = 0; y < this.Height; y++)
                        {
                            var grayVal = this.GrayMap.GetPixel(x, y);
                            var index = grayVal.A;
                            var color = ColorUtil.GetColorInRamp(index, this.ColorRamp);
                            result.SetPixel(x, y, color);
                        }
                    }

                    return ColorUtil.AdjustOpacity(result, this.Opacity);
                });

              
            }

    2013年5月9日 7:13

答案

全部回复