|
(C#) language
i am making a website in which i want to added a facility in which if the user is idle for some minutes not at the time of working but if and only if idle then it redirect to the Login Page.
So please help me...
Mitesh
|
|
|
|
|
|
Sandeep Mewara wrote: ASP.NET question
Major assumption, he could be talking about a Silverlight application - and he is still in the wrong forum
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
... or Apache/PHP, in which case, he's still....
... ... or ... or ...
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
ok so I'm just as self absorbed as Sandeep.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Yeah.
|
|
|
|
|
How can to convert XML file to Datatable via C#.
My XML file is :
<CheckRepeatedOstan sp_PersianName = "check the repeted item" >
<CheckRepeatedPerson sp_PersianName = "check which person is repeated" >
<DeleteAddressbyIdPerson sp_PersianName = "" >
<DeleteAddressType sp_PersianName = "" >
<DeleteAutoAnsRecivedSMS sp_PersianName = "" >
<DeleteAutoAnsTitle sp_PersianName = "" >
<DeleteCompitionTitle sp_PersianName = "" >
<DeleteCompititionRecivedSms sp_PersianName = "" >
<DeleteDraftGroups sp_PersianName = "" >
<DeleteDraftMessage sp_PersianName = "" >
<DeleteEmailbyIdPerson sp_PersianName = "" >
<DeleteFullGroupClickedByIdTitle sp_PersianName = "" >
<DeleteGroups sp_PersianName = "" >
<DeleteGruopAutoAns sp_PersianName = "" >
<DeletePersonByIdPerson sp_PersianName = "" >
<DeletePhonebyIdPerson sp_PersianName = "" >
<DeletePhoneType sp_PersianName = "" >
<DeleteProvince sp_PersianName = "" >
and now i wanna to have table something link bellow :
SP_Name || SP_PersianName
CheckRepeatedOstan || check the repeted item
CheckRepeatedPerson || check which person is
|
|
|
|
|
I need to work with some very large integers; about 100 decimal places. Therefore, I thought I would use the data type BigInteger. However, the following program does not compile:
using System;
using System.IO;
using System.Numeric;
class MainClass {
public static void Main()
{
BigInteger i1;
}
}
I get the following error message:
Error 1 'System.Numeric.BigInteger' is inaccessible due to its protection level C:\dev\C#.dev\test\main.cs 8 9 test
Should I be using a different data type? Why does this simple program not compile?
Thanks
Bob
|
|
|
|
|
That bizarre message is what one gets when compiling with an old .NET version. BigInteger type got introduced in .NET 4.0, hence this
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
BigInteger a = 12;
Console.WriteLine("a=" + a);
Console.ReadKey();
}
}
}
works just fine on Visual Studio 10, targetting .NET 4.0
Please note the extra s in the using statement.
|
|
|
|
|
Thanks for the response. I am back on version 3.5. Is there a bignum class in version 3.5? If so, what is it?
Bob
|
|
|
|
|
No. However you could:
- create your own; which is a painful job, the size of which depends on the exact operations you want available. Addition and multiplication are easy; division, and square rooting are hard; everything else is hard if you want maximum performance.
- read some CP articles on such subject (I once did that and I must warn you they have wildly varying quality)
- try and use a very old Java implementation (it used to also be part of Microsoft's defunct Visual J#, search for vsjlib.dll)
- look inside the .NET 4.0 implementation and port that to .NET any version using Reflector or some such;
- conclude that the one real solution is called .NET 4.0
|
|
|
|
|
Thanks for the response. I downloaded the Express Version of Studio 2010 which I believe is current. There is a newer version but it is in beta. I tried your code and I got the error message:
Error 1 The type or namespace name 'Numerics' does not exist in the namespace 'System' (are you missing an assembly reference?) C:\dev\C#.dev\test\main.cs 4 14 test
It does not like the statement:
using System.Numerics;
What am I missing?
Bob
|
|
|
|
|
The answer is in the error message: you should add a reference. Check the MSDN documentation on the types you want to use, it will tell you which namespaces you need to add a reference to, then do so in the solution pane.
BTW: this has been the way since .NET 1.0; you get a limited number of DLL's referenced for free, everything else you have to add explicitly.
|
|
|
|
|
Quick Q - I have a critical section which is to be executed only once but is invoked by many scenarios. How can I execute this thread proc and skip all the rest of the calls?
Thanks in Advance
--
Varun
|
|
|
|
|
Do you mean something like what's used in a Singleton to enable lazy instantiation?
Have an object to lock on and something to indicate that the code has already been called.
private object tolock = new object() ;
private bool initialized = false ;
...
if ( !initialized )
{
lock ( tolock )
{
if ( !initialized )
{
/* do whatever */
initialized = true ;
}
}
}
And if you are writing a Singleton, please don't, or at least read http://csharpindepth.com/Articles/General/Singleton.aspx[^]
|
|
|
|
|
Thanx a lot... Still, you recommended not to use Singleton. Why?
--
Varun
|
|
|
|
|
They're silly. I've never yet found a reason to use one. They seem to solve a problem that doesn't exist. They limit your future options. They were devised prior to C# -- in C# (since V2) a static class may be a better fit, otherwise just use a regular class.
At any rate, if you do write a Singleton (and I can't stop you), follow Skeet's advice.
|
|
|
|
|
i would like to hear more about why singleton are silly... I've a case where a server application would manage a list of users, the server could add a user, getLoggedUsers , log a user in, log out a user, get a list of all users and contact one user to send a chat request (the client contacts the server about the chat request, the server alerts the target user and then the users would chat directly), to implement the functionality of the contacts list (not a simple List<user>, sadly) i've made a static class who controls the underling List, synchronizing it with a XML file (used to serialize the list), this way, all the users contacting the server would see the same list of users.
i was thinking in replacing the static class with a singleton, you think it's a bad idea?
i would appreciate your opinion.
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
Sentenryu wrote: i was thinking in replacing the static class with a singleton, you think it's a
bad idea?
Mainly I just don't see the point. Does it work as a static class? What do you think a Singleton would provide that a static class doesn't? If the users are running in different systems then they wouldn't share the Singleton anyway -- and if it's behind a Service then it's just a black box so what difference does it make to the clients?
If you've read up on the Singleton Pattern, then you should know that it provides a shared instance -- if it isn't going to be shared, then it probably isn't the right tool for the job. Nor am I sure that a static class is either; I'd likely just instantiate one instance of a regular class.
When I wrote a chat system, it had a database and each client connected to the database server to log in/out, get the list of users, send/get messages, etc. -- I haven't gotten around to writing a Web Service for it yet, and haven't experimented with Web Services at all for two years. But I wouldn't automatically run off and write a Singleton to hide behind the Service.
|
|
|
|
|
this "chat" is a submission to my university, i can't use a database and need to user a server application that communicates witch tcp/ip (if i can use a database, this wouldn't be a problem )
in theory it works with the static class, the problem is that i'm afraid it's not safe, what happens if two users connected (so, two threads) request the server to add a new user, then the server call the Add method 2 times simultaneously, the Add method writes a XML file and then reads it again (yes, poor implementation, hopefully not mine).
the point in making it a static class is that in this way all the threads would have access to the same list of users, but i've seen very strange comportment of this class, in the static constructor, the class instantiate and fills the list of contacts, i've put a breakpoint here and tested, for some reason, when i called the add method, the static constructor was not executed, with scared the sh*t out of me, everything was null, then, when the method returned (the method executed with success, even with the List<users> null, they were able to add to it, i don't know how) then the execution point moved to the static constructor, in my breakpoint.
after much test, i've found that when 2 threads call a method of this class, the secund call execute before the static constructor, i think it's a bug with my installation of visual studio, i prefer not to consider that this can occur i in a production environment, but just in case...
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
Sentenryu wrote: in theory it works with the static class, the problem is that i'm afraid it's
not safe, what happens if two users connected (so, two threads) request the
server to add a new user, then the server call the Add method 2 times
simultaneously, the Add method writes a XML file and then reads it again (yes,
poor implementation, hopefully not mine).
That question has nothing to do with whether it is a singleton or not.
Sentenryu wrote: but i've seen very strange comportment of this class
That has nothing to do with the correct behavior of the class. Could be something odd with how you were using the debugger, could be mismatch in classes, could bug in your code or something even more exotic like a bug in the debugger.
I wouldn't get to wrapped up in the implementation of the idea of a singleton.
Conceptually a singleton is a representation of a single instance of a class. Nothing magical about that. You can use a static class to manage the access to a single instance (a different class) without strictly implementing the singleton pattern and yet still conceptually implement it.
|
|
|
|
|
Sentenryu wrote: submission to my university
If it's classwork, then considering and trying out different ways of implementing it is a good thing.
Sentenryu wrote: if two users connected (so, two threads)
My understanding is that if they're in separate App Domains, then a Singleton won't help anyway -- each would have its own instance. And that would be true of a static class as well. You may need to look into a Mutex, which is sort of like the locking object, but system-wide.
|
|
|
|
|
now you have confused me, the console application that acts as the server is the only one who will use this class, what will be sent to the client is a xml response of their request. the threads are created in the server with a ThreadPool (subject to change, i think i'm using the wrong class, maybe i'm confusing it with java's ThreadPool...) in my understanding, all of those threads run in the App Domain of the console application, is this wrong?
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
Sentenryu wrote: all of those threads run in the App Domain of the console application
Oh, yes, but then why do you have threads?
Sentenryu wrote: the console application
The main method of which is static already, so I'd likely stick with static.
Hmmm... so, if I understand what you're saying, each client makes a connection to the Server and gets its own thread, which I suppose is a session, and it continues to interact with the server that way until it disconnects?
I'm not sure that's a good architecture*, but not being an expert on that sort of thing, I'd better keep quiet and let others provide guidance.
* I'm fairly sure that a "connectionless" technique is more robust.
|
|
|
|
|
i'm just very bad in English =p
there's no logical connection from the client to the server, the client just sends a request and the server responds, after the response, there's no more link between the client and the server, the threads are used so the server can serve more than one client at a time.
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|