예제 #1
0
 public void clear()
 {
     using (MutexObject.section(_mutex))
     {
         FileTools.deletePath(_messageDir);
     }
 }
예제 #2
0
        public WorkingDir(string lDir)
        {
            _dir = Path.Combine(FileTools.getTMP(), lDir);

            FileTools.deletePath(_dir);
            Directory.CreateDirectory(_dir);
        }
예제 #3
0
 public void Dispose()
 {
     if (_dir != null)
     {
         string dir = _dir;
         _dir = null;
         FileTools.deletePath(dir);
     }
 }
예제 #4
0
            public void send(Queue <byte[]> sendData)
            {
                //Stopwatch sw = new Stopwatch(); // test

                //sw.Reset();
                //sw.Start();
                using (MutexObject.section(_mutex))
                {
                    //sw.Stop();
                    //laps.Add(sw.Elapsed.TotalMilliseconds);
                    //sw.Reset();
                    //sw.Start();
                    getMessageRange();
                    //sw.Stop();
                    //laps.Add(sw.Elapsed.TotalMilliseconds);
                    //sw.Reset();
                    //sw.Start();
                    tryRenumber();
                    //sw.Stop();
                    //laps.Add(sw.Elapsed.TotalMilliseconds);
                    //sw.Reset();
                    //sw.Start();

                    if (_gmrLastNo == -1)
                    {
                        FileTools.deletePath(_messageDir);
                        Directory.CreateDirectory(_messageDir);
                    }
                    //sw.Stop();
                    //laps.Add(sw.Elapsed.TotalMilliseconds);
                    //sw.Reset();
                    //sw.Start();
                    using (FileStream wfs = new FileStream(
                               Path.Combine(_messageDir, StringTools.zPad(_gmrLastNo + 1, 4)),
                               FileMode.Create,
                               FileAccess.Write
                               ))
                        foreach (byte[] block in sendData)
                        {
                            wfs.Write(block, 0, block.Length);
                        }
                    //sw.Stop();
                    //laps.Add(sw.Elapsed.TotalMilliseconds);
                    //sw.Reset();
                    //sw.Start();
                }
                //sw.Stop();
                //laps.Add(sw.Elapsed.TotalMilliseconds);
                //sw.Reset();
                //sw.Start();
                _messagePostEvent.set();
                //sw.Stop();
                //laps.Add(sw.Elapsed.TotalMilliseconds);
            }
예제 #5
0
            private byte[] tryRecv()
            {
                using (MutexObject.section(_mutex))
                {
                    getMessageRange();

                    if (_gmrFirstNo != -1)
                    {
                        String file     = Path.Combine(_messageDir, StringTools.zPad(_gmrFirstNo, 4));
                        byte[] recvData = File.ReadAllBytes(file);

                        FileTools.deletePath(file);

                        if (_gmrFirstNo == _gmrLastNo)
                        {
                            FileTools.deletePath(_messageDir);
                        }

                        return(recvData);
                    }
                }
                return(null);
            }