|
|
Webclient supports only upLoadFile and UpLoadData , But how can i use to append a file which is already existing in Server.
if you have any sample code to perform Append please provide me i will be great help
Thanks in Advance.
|
|
|
|
|
Member 4181669 wrote: But how can i use to append a file which is already existing in Server.
You need to read the existing file contents, do the appending from your application and upload the new file. FTP doesn't provide a way to append to a file.
|
|
|
|
|
Hi. I've a multithreaded service application with many threads accessing a comom resource. I have a typical Readers/Writers environment, where many threads may read at the same time but only one can write to the resource, exclusively.
The thing is, whenever two threads (or more) asks for writing permission, I do not need to wait for the first thread to finish, I can just abort it (the first thread is no longer needed) and execute the second thread. Since writing is an expensive operation, it's desirable that I abort the first thread and execute the second.
So, here's my doubt: if I abort a thread that holds a lock, will it release the lock?
My simplified code looks like this:
private static System.Threading.Thread WritingThread =
System.Threading.Thread(MyClass.PerformWriting)
private void TryWrite()
{
If (WritingThread.IsAlive)
WritingThread.Abort();
WritingThread.Start();
}
private void PerformWriting()
{
MyReaderWriterLockSlim.EnterWriteLock();
try{
}
finally{
MyReaderWriterLockSlim.ExitWriteLock();
}
}
So here's the deal. I have a commom fixed writing thread for everybody, so I can test if the thread is already running, and if is, I can just abort it and initiate it again. This get the effect of aborting the first writing and executing the second. Whenever a thread needs to write to the resouce, it just calls the TryWrite function. The original calling thread doesn't need to wait the end of the operation, so it returns and finishes.
But, since "writing operation" takes a long time, it is more likely that the WritingThread will be aborted when it is writing, that is, when it holds the lock.
Is that code ok, or it will deadlock when the thread gets aborted in the middle of the writing?
Regards,
Leonardo Muzzi
|
|
|
|
|
Hi,
aborting a thread is a bad idea, as it (1) may not occur right away (e.g. when inside some I/O operations) and (2) will get kicked out in an unknown state, without getting a chance for cleaning up after itself.
so the recommendation is not to abort at all, rather to implement a cooperative thread exit scheme, where the thread regularly checks a flag to make sure it should continue its work or exit.
And as you would abort a thread to start a similar thread, there is no need to do any thread operation at all, just tell the thread to abandon its current job and start executing the new job.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Good ! I'll try implementing the "restart flag" inside the writing operation.
But, let's say I can not interfere in the writing code (I don't know if I can, not my implementation), so I can't change the writing operation to test a flag eventually. Any other ideas?
Thanks !
Regards,
Leonardo Muzzi
|
|
|
|
|
I'm thinking about implementing another thread that just sleeps for a while and checks for the flag, and abort the WritingThread if it finds the restart flag true. This new thread would hold the lock and therefore I can make sure it will release it.
Still, I'm aborting threads and creating new ones.
Is it good?
Regards,
Leonardo Muzzi
|
|
|
|
|
You don't need a thread to hold a lock; you can implement the thread stuff and the lock inside a class.
BTW: when you reply to yourself, you're the one getting the mail notification...
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
This[^] is the best I ever found about .NET threading.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Excelent text! This is what I needed to know:
"All catch/finally blocks are honored, and never aborted mid-stream"
So the first code would work.
I'll check if I can change the writing operation to test a restart flag anyway!
Thanks for the help !
(sorry for the self-reply)
Regards,
Leonardo Muzzi
|
|
|
|
|
You're welcome.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
"All catch/finally blocks are honored, and never aborted mid-stream..."
...but code which relies upon certain instructions not throwing exceptions may be broken if they do so. See the article's comments about 'using'. By the sound of it, using abort exceptions doesn't sound very safe. Using interrupt would seem much safer, provided that any time-consuming loops that don't engage in managed sleeping test a flag for whether they should exit.
The "using" directive is nice in many ways--it's too bad that there are so many wrinkles when using it. If a constructor could take a byRef parameter indicating where the new object should be stored, and if it could store the newly-created object there before leaving its outermost try/catch block, one could emulate a 'Using' in such a way as to avoid leaving dangling resources in case of an abort. Unfortunately, I don't know any way to make anything remotely like that work as smoothly as "using".
Too bad iDisposable seems to have been an afterthought (unlike Finalize, which is common to all objects). If Finalize took a parameter which indicated whether to perform a garbage-collect cleanup, explicit disposal, or failed-object-creation cleanup (objects that wanted to receive a garbage-collect cleanup would have to register) that would have simplified a lot of things.
|
|
|
|
|
My web site calling to the proxy web service using javascript and proxy web service calling actual local web service. Till yesterday its working fine. now suddenly its giving me error.When i run project first few (2-3) web request giving response properly but after that its giving me following error in fiddler.
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Net.WebException: The request failed with HTTP status 403: Access Forbidden.
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at localhost.Service.ProcessGetRequest(String data) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\globexmall\d53d5ac4\3be925d4\App_WebReferences.xxn2txa_.0.cs:line 51
at Globexmall.Proxy.GetResponse(XmlDocument xmlData) in c:\Inetpub\wwwroot\GlobexMall\App_Code\Proxy.cs:line 59
--- End of inner exception stack trace ---
using following code i am making call to the local web service
[WebMethod]
public string GetResponse(XmlDocument xmlData)
{
localhost.Service Wservice = new localhost.Service();
XmlNode xmlResponse = Wservice.ProcessGetRequest(xmlData.OuterXml);
XmlDocument wsResponse = new XmlDocument();
wsResponse.AppendChild(wsResponse.ImportNode(xmlResponse, true));
return wsResponse.InnerXml;
}
If anyone knows the answer then plz help me as soon as possible
Thanx in advance
|
|
|
|
|
Your first clue is here:
"HTTP status 403: Access Forbidden"
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi al
how can i convert the integer into string on linq database by using c#
|
|
|
|
|
int.Parse(str)
ToshiyaTSURU <turutosiya@gmail.com>
http://www.google.com/profiles/turutosiya
|
|
|
|
|
For higher performance you can use Convert.ToInt32
|
|
|
|
|
hi all,
i just want to know when the .net3.5 (WCF,WPF,..), ajax are released.. release dates
are they available in 2007..
thanks alot in advance
|
|
|
|
|
Don't cross post, you've already asked this question
only two letters away from being an asset
|
|
|
|
|
I have created FTP Client project in vb.net.
It works on Passive mode only.
Now i want to add Unicode support code and Active transfer mode code.
Please help me to find out the code or links .
|
|
|
|
|
I was wondering if it is possible to show a Vista style progress window, like you get when copying a number of files. Also, for example, Windows Live Mail uses it when moving email messages. Is there a .NET class for this available? Actually I would like to set the text in the window and value of the ProgressBar myself and execute certain pieces of code myself, depending on the value of the ProgressBar.
If you do not understand what I mean, please see this image:
click here
Thanks.
|
|
|
|
|
This looks like it may be what you want. .NET Animation Control[^]
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thanks very much for your post, however, it does not appear to work in Vista. Also, this link doesn't work in Vista either. Also I discovered the animations come from shell32.dll. Perhaps they aren't included in that file in Vista. I will search somewhat more and post if I find something working.
|
|
|
|
|
|
A good find.
Thanks for posting the link,
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|