Ejemplo n.º 1
0
        private void LoadFromFileAsync(ContentContainer cc)
        {
            // Try loading content on another thread
            bool s = ThreadPool.QueueUserWorkItem((o) =>
            {
                // Load content from file
                object content = null;
                using (Stream stream = new FileStream(_basePath + cc.Path, FileMode.Open, FileAccess.Read))
                {
                    // Process file content
                    content = cc.Process(stream);

                    // Close stream
                    stream.Close();
                }

                // Add content to container
                cc.Content         = content;
                cc.Hash            = HashObject(cc.Content);
                cc.LoadingComplete = true;
            });

            // Something went wrong when trying to queue the loading method
            if (!s)
            {
                throw new Exception("aids");
            }
        }
Ejemplo n.º 2
0
        //
        private void LoadFromFile(ContentContainer cc)
        {
            // Load content
            object content = null;

            using (Stream stream = new FileStream(_basePath + cc.Path, FileMode.Open, FileAccess.Read)) // Open stream
            {
                // Process file content
                content = cc.Process(stream);

                // Close stream
                stream.Close();
            }

            // Add content to container
            cc.Content         = content;
            cc.Hash            = HashObject(content);
            cc.LoadingComplete = true;
        }