Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Cant Write Large Text File

Cant Write Large Text File

Scheduled Pinned Locked Moved C#
performancemobiledatabasedotnetcom
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    salamonty86
    wrote on last edited by
    #1

    Dear all, I want to create a large .txt file but when i run my code i got a strange thing, A messagebox say's: "No Symbols are loaded for any call stack frame. The source code cannot be displayed." and a warning say's "The CLR has been unable to transition from COM context 0x1c2000 to COM context 0x1c2170 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations." My code is: string prev=""; string connectionString = "Provider=Microsoft.JET.OLEDB.4.0;data source=E:\\ICA_Newspapers.mdb"; OleDbConnection conn = new OleDbConnection(connectionString); string sql = "SELECT * FROM All_Analyzed_Corpus"; OleDbCommand cmd = new OleDbCommand(sql, conn); conn.Open(); OleDbDataReader reader; reader = cmd.ExecuteReader(); StreamWriter tw = new StreamWriter(Application.StartupPath + "\\TaggedCorpus.txt"); StringBuilder text = new StringBuilder(); while (reader.Read()) { //if new line if (reader.GetValue(1).ToString() == "/D") { //if end of line text.Append("</s>"); //text.Capacity = text.Length; // write a line of text to the file tw.WriteLine(text); tw.Flush(); text = text.Remove(0, text.Length); text.Append("<s> "); prev = "/D"; } else if (reader.GetValue(1).ToString() == "/T" && prev != "/D") { //if end of line text.Append("</s>"); //text.Capacity = text.Length; // write a line of text to the file tw.WriteLine(text); tw.Flush();

    C 1 Reply Last reply
    0
    • S salamonty86

      Dear all, I want to create a large .txt file but when i run my code i got a strange thing, A messagebox say's: "No Symbols are loaded for any call stack frame. The source code cannot be displayed." and a warning say's "The CLR has been unable to transition from COM context 0x1c2000 to COM context 0x1c2170 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations." My code is: string prev=""; string connectionString = "Provider=Microsoft.JET.OLEDB.4.0;data source=E:\\ICA_Newspapers.mdb"; OleDbConnection conn = new OleDbConnection(connectionString); string sql = "SELECT * FROM All_Analyzed_Corpus"; OleDbCommand cmd = new OleDbCommand(sql, conn); conn.Open(); OleDbDataReader reader; reader = cmd.ExecuteReader(); StreamWriter tw = new StreamWriter(Application.StartupPath + "\\TaggedCorpus.txt"); StringBuilder text = new StringBuilder(); while (reader.Read()) { //if new line if (reader.GetValue(1).ToString() == "/D") { //if end of line text.Append("</s>"); //text.Capacity = text.Length; // write a line of text to the file tw.WriteLine(text); tw.Flush(); text = text.Remove(0, text.Length); text.Append("<s> "); prev = "/D"; } else if (reader.GetValue(1).ToString() == "/T" && prev != "/D") { //if end of line text.Append("</s>"); //text.Capacity = text.Length; // write a line of text to the file tw.WriteLine(text); tw.Flush();

      C Offline
      C Offline
      Covean
      wrote on last edited by
      #2

      It seems that a COM object needs to respond within 60 seconds, but you create someting in this time. Is this an operation you run in your main tread (or the thread which created a window)? I would try to execute Application.DoEvents(); every loop iteration.

      Greetings Covean

      S 1 Reply Last reply
      0
      • C Covean

        It seems that a COM object needs to respond within 60 seconds, but you create someting in this time. Is this an operation you run in your main tread (or the thread which created a window)? I would try to execute Application.DoEvents(); every loop iteration.

        Greetings Covean

        S Offline
        S Offline
        salamonty86
        wrote on last edited by
        #3

        When I did Application.DoEvents(); no message appears but the file size stopped at 7805 kb and the program stopped and thats cant be because the file must end with the last record in my database table.

        C 1 Reply Last reply
        0
        • S salamonty86

          When I did Application.DoEvents(); no message appears but the file size stopped at 7805 kb and the program stopped and thats cant be because the file must end with the last record in my database table.

          C Offline
          C Offline
          Covean
          wrote on last edited by
          #4

          Are there no exceptions? I looked over your code and couldn't find any problem, so I tried if there is maybe a problem with the filesize (I haven't really awaited that there is an error and there is no error. I was able to create an 9GB large text file without problems). Do you use any other COM-objects in your project? At next I would try to do this database-"export" in an own thread.

          Greetings Covean

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups