Exemplo n.º 1
0
        public void SingleAsyncRead(Random random)
        {
            lock (this)
            {
                _asyncReadSends++;
            }
            if (random.NextDouble() > 0.90)
            {
                //read a non existant asset
                _server.GetAssetAsync("00000000000000000000000000000000",
                                      delegate(Asset asset, AssetServerError e)
                {
                    if (e == null)
                    {
                        Console.WriteLine("Async read expected to error, but no error caught!");
                    }

                    lock (this)
                    {
                        _asyncReadReturns++;
                        Console.WriteLine("async:  sent: " + _asyncReadSends + " rcvd: " + _asyncReadReturns);
                    }
                }
                                      );
            }
            else
            {
                //read an existing asset
                int index = (int)Math.Floor(_assetUuids.Count * random.NextDouble());
                _server.GetAssetAsync(_assetUuids[index],
                                      delegate(Asset asset, AssetServerError e)
                {
                    if (e != null)
                    {
                        Console.WriteLine("Async read expected no error, but error caught! " + e.ToString());
                    }

                    lock (this)
                    {
                        _asyncReadReturns++;
                        Console.WriteLine("async:  sent: " + _asyncReadSends + " rcvd: " + _asyncReadReturns);
                    }
                }
                                      );
            }
        }