Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/20/11 10:20:19 (13 years ago)
Author:
epitzer
Message:

Lock bitmap while saving and remove configuration info when other exceptions occur (#1560)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence/3.3/Tests/UseCases.cs

    r6356 r6446  
    12891289    }
    12901290
     1291    [TestMethod]
     1292    public void ConcurrentBitmapTest() {
     1293      Bitmap b = new Bitmap(300, 300);
     1294      Random r = new Random();
     1295      for (int x = 0; x<b.Height; x++) {
     1296        for (int y = 0; y<b.Width; y++) {
     1297          b.SetPixel(x, y, Color.FromArgb(r.Next()));
     1298        }
     1299      }
     1300      Task[] tasks = new Task[20];
     1301      byte[][] datas = new byte[tasks.Length][];
     1302      for (int i = 0; i<tasks.Length; i++) {
     1303        tasks[i] = Task.Factory.StartNew((idx) => {
     1304          using (var stream = new MemoryStream()) {
     1305            XmlGenerator.Serialize(b, stream);
     1306            datas[(int)idx] = stream.ToArray();
     1307          }
     1308        }, i);
     1309      }
     1310      Task.WaitAll(tasks);
     1311    }
     1312
    12911313    [ClassInitialize]
    12921314    public static void Initialize(TestContext testContext) {
Note: See TracChangeset for help on using the changeset viewer.