Error help

J

Jarry

The CLR has been unable to transition from COM context 0x1b1f20 to COM
context 0x1b2090 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.

Hi there. I'm a bit new, and I got this Error message occasionly when I
load my program, maybe when I switch to another program when I'm
loading it up, I don't know . It has a pretty big memory consumption
when it loads up, as it loads an array from a text file, something like
this:

Dim openFileDialog1 As New OpenFileDialog()
openFileDialog1.FileName =
My.Application.Info.DirectoryPath & "\test.txt"
Dim sr As New System.IO.StreamReader(openFileDialog1.OpenFile)
If Not (sr Is Nothing) Then
For i = 1 To 50
myArray(i) = sr.ReadLine
Next
End If
sr.Close()

Because it only happens sometimes, it's hard to find what is
influencing it? Any ideas n how to stop it happening, or catch it
better?

Thanks in advance
 
T

The Grim Reaper

The first most obvious thing I'd do is stick a DoEvents() in the For.. Next
loop;

For i = 1 to 50
myArray(i) = sr.ReadLine
Application.DoEvents()
Next

I believe that sub is in System.Windows.Forms. As an alternative, you can
use
System.Threading.Thread.Sleep(0) instead.

I wholeheartedly agree that "COM context 0x1b1f20 to COM context 0x1b2090"
is abolutely
blinkin' useless unless you're a C++ or machine language type expert!!
__________________________________
The Grim Reaper
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top