Click here to Skip to main content
15,910,886 members
Home / Discussions / C#
   

C#

 
GeneralRe: sql connection pool feature Pin
teknolog12310-Apr-10 5:51
teknolog12310-Apr-10 5:51 
AnswerRe: sql connection pool feature Pin
PIEBALDconsult10-Apr-10 5:57
mvePIEBALDconsult10-Apr-10 5:57 
AnswerRe: sql connection pool feature Pin
Eddy Vluggen10-Apr-10 22:49
professionalEddy Vluggen10-Apr-10 22:49 
Questionsetting datasource of Grid View Problem Pin
shaina223110-Apr-10 2:07
shaina223110-Apr-10 2:07 
GeneralRe: setting datasource of Grid View Problem Pin
Khaniya10-Apr-10 2:38
professionalKhaniya10-Apr-10 2:38 
GeneralRe: setting datasource of Grid View Problem Pin
shaina223110-Apr-10 2:53
shaina223110-Apr-10 2:53 
AnswerRe: setting datasource of Grid View Problem Pin
Khaniya10-Apr-10 23:04
professionalKhaniya10-Apr-10 23:04 
QuestionError while uploading large file Pin
sjs4u9-Apr-10 20:16
sjs4u9-Apr-10 20:16 
Hi,

I am using webclient while uploading large file(135MB) using windows application. My Code works but when it reaches to stream.close() it showing following error

Error:-

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


So because of that my file is not uploaded. what is the problem?

My Code is:-




WebClient client = new WebClient();
Stream stream = client.OpenWrite(remoteFilename, "PUT");

// The buffer size is set to 2kb
const int buffLength = 2048;
byte[] buff = new byte[buffLength];
int contentLen;

// Opens a file stream (System.IO.FileStream) to read the file
// to be uploaded
FileStream fs = fileInf.OpenRead();

int doneSoFar = 0;
// Read from the file stream 2kb at a time
contentLen = fs.Read(buff, 0, buffLength);
//added for accurate progress
doneSoFar += contentLen;
setItemStatus("Uploading");
while (contentLen != 0)
{
setItemProgress(doneSoFar, fileInf.Length);

// Write Content from the file stream to the FTP Upload Stream
stream.Write(buff, 0, contentLen);
contentLen = fs.Read(buff, 0, buffLength);
doneSoFar += contentLen;
}

// Close the file stream and the Request Stream
stream.Close();
fs.Close();





Thanks
sjs
AnswerRe: Error while uploading large file Pin
Not Active10-Apr-10 1:05
mentorNot Active10-Apr-10 1:05 
GeneralRe: Error while uploading large file [modified] Pin
sjs4u10-Apr-10 1:31
sjs4u10-Apr-10 1:31 
GeneralRe: Error while uploading large file Pin
Not Active10-Apr-10 2:02
mentorNot Active10-Apr-10 2:02 
GeneralRe: Error while uploading large file Pin
sjs4u10-Apr-10 2:14
sjs4u10-Apr-10 2:14 
GeneralRe: Error while uploading large file Pin
Not Active10-Apr-10 2:31
mentorNot Active10-Apr-10 2:31 
Questionhow to IF?! Pin
Jassim Rahma9-Apr-10 11:55
Jassim Rahma9-Apr-10 11:55 
AnswerRe: how to IF?! [modified] Pin
Luc Pattyn9-Apr-10 12:01
sitebuilderLuc Pattyn9-Apr-10 12:01 
GeneralRe: how to IF?! Pin
Jassim Rahma9-Apr-10 12:04
Jassim Rahma9-Apr-10 12:04 
GeneralRe: how to IF?! Pin
Migounette9-Apr-10 12:23
Migounette9-Apr-10 12:23 
GeneralRe: how to IF?! Pin
harold aptroot9-Apr-10 12:03
harold aptroot9-Apr-10 12:03 
GeneralRe: how to IF?! Pin
Jassim Rahma9-Apr-10 12:06
Jassim Rahma9-Apr-10 12:06 
GeneralRe: how to IF?! Pin
harold aptroot9-Apr-10 12:13
harold aptroot9-Apr-10 12:13 
GeneralRe: how to IF?! Pin
Jassim Rahma9-Apr-10 12:30
Jassim Rahma9-Apr-10 12:30 
GeneralRe: how to IF?! Pin
harold aptroot9-Apr-10 12:31
harold aptroot9-Apr-10 12:31 
GeneralRe: how to IF?! Pin
Jassim Rahma9-Apr-10 12:36
Jassim Rahma9-Apr-10 12:36 
AnswerRe: how to IF?! Pin
AspDotNetDev9-Apr-10 16:18
protectorAspDotNetDev9-Apr-10 16:18 
GeneralRe: how to IF?! Pin
harold aptroot10-Apr-10 1:04
harold aptroot10-Apr-10 1:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.