|
I'm disturbed about static function reference object parameters thread safety.
Local parameters in the function are safe, they are created for each thread, e.g. cropped image.
2nd parameter is value object Rectangle is also safe, copy is created as you pass it.
1st parameter is reference object Bitmap. There is no writing to that parameter as you can see in the code. There should not be any difference if you modify it either if it is safe.
My question is whether parameters to static function are passed in a thread safe approach?
That is do they have the same thread safety as local variables in that static function body?
Чесноков
|
|
|
|
|
Chesnokov Yuriy wrote: whether parameters to static function are passed in a thread safe approach?
the question doesn't make sense. there is no such thing as "passing parameters in a thread-safe way".
parameters get handled by the method called, whether it is static or not.
and they exist on behalf of the caller, who could or could not share them with other code on other threads.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
May be I've overworked but having N threads in Crop() function.
cropped is local variable and safe, each thread has its own object created.
Each thread has its own Bitmap passed to Crop() .
Will 1st parameter image in Crop() function when accessed by one of N threads at the same time be refering to its own thread?
Чесноков
|
|
|
|
|
when a reference type is passed to a method (static or not), nothing happens to the object. All that happens is the method is given a way to work with that object.
objects in general don't know about threads, they don't "refer to a thread".
Chesnokov Yuriy wrote: Each thread has its own Bitmap passed to Crop().
So what problem could arise?
you can open 10 distinct documents with MS Word at the same time; they won't interfere with one another; executing the same code on different objects does not cause failure. Only having multiple threads working on the same data may cause problems.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
As far as I know, passing parameters to a static method is not different than passing them to instance ones, I mean, if another thread might be writing the image parameter of your sample, then you should explicitly synchronize the threads to make sure the program will not try to read and write at the same time, becouse in that case your reading operations might read "trash bytes" due to a not finished writing operation.
|
|
|
|
|
hello,
i have been using using Microsoft.Office.Interop.Word in my webserver (yes, i know it is not recommended)
when i ran it on my machine it runs fine but when running on the server i get time out on the line:
Documents.Open //when trying to open the file.
is there something im missing?
is there a better way to edit word document within web servers/ websites? (i can't create a new one using string builder or outputting into file i need to edit an existing one that sits on the server)
any input will be appreciated as I'm stuck on this for few days already...
thanks
|
|
|
|
|
Filepaths.
That is usually the problem, check them before anything else.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
thank you but i already checked that and the file exists...
|
|
|
|
|
Could be a lot of reasons. Security settings: Word creates a ~MyDocucemt.docx file in the directory - has the user write access to that directory.
Or a message box popping up from Word (e.g. confirm conversion, confirm share) - nobody will be able to click OK there...
|
|
|
|
|
Thank you everyone for trying, checked all ideas but it didnt work
thank you anyway
|
|
|
|
|
Hi All,
I want to pass only the single object of
dtoSourece sObj = new dtoSourece(); for xml serialization.
but cannot access sObj.applicant.firstname
Please help me with this?
static void Main(string[] args)
{
dtoSourece sObj = new dtoSourece();
sObj.name = "ram";
sObj.age = "25";
jlvformApplicant s = new jlvformApplicant();
s.firstname = "india";
Console.WriteLine("india=" + sObj.applicant.firstname);//getting error
Console.ReadLine();
}
class dtoSourece
{
public string name { get; set; }
public string age { get; set; }
private jlvformApplicant applicantField;
public jlvformApplicant applicant
{
get
{
return this.applicantField;
}
set
{
this.applicantField = value;
}
}
}
public class jlvformApplicant
{
private string firstnameField;
private string lastnameField;
/// <remarks>
/// <remarks>
public string firstname
{
get
{
return this.firstnameField;
}
set
{
this.firstnameField = value;
}
}
/// <remarks>
public string lastname
{
get
{
return this.lastnameField;
}
set
{
this.lastnameField = value;
}
}
}
Ramkumar
("When you build bridges you can keep crossing them. ")
http://ramkumarishere.blogspot.com
|
|
|
|
|
it would be so much easier to read if you used the formatting provided by CP rather than just plonking the code in like that.
As far as I can see from a quick look, your dtoSourec object has a property applciant which is never set to any value.
So if you do something like
dtoSourece sObj = new dtoSourece();
sObj.name = "ram";
sObj.age = "25";
jlvformApplicant s = new jlvformApplicant();
s.firstname = "india";
sObj.applicant= s;
Console.WriteLine("india=" + sObj.applicant.firstname);
Console.ReadLine();
You should be OK/.
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
You are not setting the applicant property of your sObj which is why I suspect that you are getting the error.
BTW: You will get more help, more quickly, if you:
a) put your code inside <pre> your code goes here </pre> tags. Doing that makes it easier to read.
b) give full information about the problem you are having. e.g. the exact wording of the exception.
In your case I suspect that the error is a 'null reference exception' but I can't be sure.
My suggestion to resolve your problem is below.
static void Main(string[] args)
{
dtoSourece sObj = new dtoSourece();
sObj.name = "ram";
sObj.age = "25";
jlvformApplicant s = new jlvformApplicant();
s.firstname = "india";
sObj.applicant = s;
Console.WriteLine("india=" + sObj.applicant.firstname);
Console.ReadLine();
}
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.”
I wouldn't let CG touch my Abacus!
When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.
|
|
|
|
|
Thanks
Ramkumar
("When you build bridges you can keep crossing them. ")
http://ramkumarishere.blogspot.com
|
|
|
|
|
My pleasure.
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.”
I wouldn't let CG touch my Abacus!
When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.
|
|
|
|
|
You haven't set sObj.applicant to a value so it is null.
Your missing
sObj.applicant = s;
Just a note for the future. wrap your code in the pre tags (code block) so the code is formated. It makes it easier to read.
"You get that on the big jobs."
|
|
|
|
|
You really should read the other answers before posting.
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.”
I wouldn't let CG touch my Abacus!
When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.
|
|
|
|
|
to be fair, you posted the same answer as me after my post
(I wouldn't point it out, but the op thanked you
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
_Maxxx_ wrote: to be fair, you posted the same answer as me after my post
I was typing mine as yours was being posted, so I was not aware that you had done so, NOT 4 hours later as in this case.
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.”
I wouldn't let CG touch my Abacus!
When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.
|
|
|
|
|
Hi,
I have a DataGridView that is bound to a list of objects through it's
datasource property and the first column is checkbox column.
If I try to change the checkstate for the first time, CellValueChanged event is not firing. From the second time its firing. I tried with the below events, but of no use
dgvAwards_CellStateChanged
dgvAwards_CellMouseClick
dgvAwards_CellValuePushed
Is there any other event which can fire at the first time. Thanks in advance
|
|
|
|
|
|
Thank you, Alan.. its working
|
|
|
|
|
Hi,
The SaveFileDialog that opens up while clicking the export button of the CrystalReportViewer by default filters the predefined file types. Is it possible to custom define which files to be filtered? Please help. Regards.
modified on Sunday, February 20, 2011 9:00 AM
|
|
|
|
|
Hi.
I was wondering if you could give me some information about Python.
I downloaded it from Python.Org(Python 3.1.3).And install it.
When i run it(IDLE (Python GUI)) a window lik Cmd is shown(title=Python Shell)!!!.
Is that python? isn't it hard to make proram with it?How have GUI? how to add controls on a form or..... like the thing we do in C#??!!
Actually,My teacher at universiy told me that making program with Python is easier than C#!!and i couldn't say anything beacuse i don't know what Python is.I just said, maybe but its 2 years that C# have taken me and i my not change it.
Of course i Googled it,But finally came here in CODEProject.
Thank you.
CanI
|
|
|
|
|
What I think you want to do is use IronPython. It's for the .Net framework.
IronPython.Net/[^]
EDIT =============
Why was this answer voted a 1? In order to properly evaluate which language he wants to use, it's important that he know about his options. I've never personally seen Iron Python, but it's his best option if he wants to compare it against C#.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
modified on Sunday, February 20, 2011 12:55 PM
|
|
|
|