Skip to content

Instantly share code, notes, and snippets.

@immengineer
Created February 17, 2018 04:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save immengineer/5513acc169ba60d1a6ef1d017b5328d5 to your computer and use it in GitHub Desktop.
Save immengineer/5513acc169ba60d1a6ef1d017b5328d5 to your computer and use it in GitHub Desktop.
MemoryMappedFile 送信側
public partial class Form1 : Form
{
private MemoryMappedFile mmf;
public Form1()
{
InitializeComponent();
try
{
mmf = MemoryMappedFile.CreateNew("Test", 1024);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
this.Close();
}
}
private void button1_Click(object sender, EventArgs e)
{
try
{
using (var stream = mmf.CreateViewStream())
using (StreamWriter sw = new StreamWriter(stream))
{
DateTime dt = DateTime.Now;
sw.Write(dt.ToString());
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
mmf.Dispose();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment