Search Results

Search found 312 results on 13 pages for 'invalidate'.

Page 6/13 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • saved image in the picturebox shows no preview

    - by Nivas
    Hi iam new to C# and have loaded the image in the picture box using menustrip and have displayed some text using picturebox_Paint and label. now i tried to save the image (with image and text) using save event from the menustrip. in the saved location the file shows as no preview avaliable and when i tried to open the file it shows out of memory. can any one say where iam going worng.... my coades private void openToolStripMenuItem_Click(object sender, EventArgs e) { string file = ""; OpenFD.FileName = ""; OpenFD.Title = "open image"; OpenFD.InitialDirectory = "C"; OpenFD.Filter = "JPEG|.jpg|Bmp|.bmp|All Files|..*"; if (OpenFD.ShowDialog() == DialogResult.OK) { file = OpenFD.FileName; pictureBox1.Image = Image.FromFile(file); sz = pictureBox1.Size; a=sz.Width; b= sz.Height; } private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { switch (e.Button) { case MouseButtons.Left: { rect = new Rectangle(rect.Left, rect.Top, e.X - rect.Left, e.Y - rect.Top); this.Invalidate(); y = flag.e; Application.DoEvents(); break; } } } private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { rect = new Rectangle(e.X, e.Y, 0, 0); this.Invalidate(); } private void pictureBox1_Paint(object sender, PaintEventArgs e) { using (Pen pen = new Pen(Color.Red, 2)) e.Graphics.DrawRectangle(pen, rect); //e.Graphics.DrawString(label1.Text, label1.Font, new // SolidBrush(label1.ForeColor), label1.Left - pictureBox1.Left, label1.Top - pictureBox1.Top); if (label1.TextAlign == ContentAlignment.TopLeft) { e.Graphics.DrawString(label1.Text, label1.Font, new SolidBrush(label1.ForeColor), label1.Bounds); } else if (label1.TextAlign == ContentAlignment.TopCenter) { SizeF size = e.Graphics.MeasureString(label1.Text, label1.Font); float left = ((float)this.Width + label1.Left) / 2 - size.Width / 2; RectangleF rect1 = new RectangleF(left, (float)label1.Top, size.Width, label1.Height); e.Graphics.DrawString(label1.Text, label1.Font, new SolidBrush(label1.ForeColor), rect1); } else { SizeF size = e.Graphics.MeasureString(label1.Text, label1.Font); float left = (float)label1.Width - size.Width + label1.Left; RectangleF rect1 = new RectangleF(left, (float)label1.Top, size.Width, label1.Height); e.Graphics.DrawString(label1.Text, label1.Font, new SolidBrush(label1.ForeColor), rect1); } label1.Top = rect.Top; label1.Left = rect.Left; label1.Width = rect.Width; label1.Height = rect.Height; } private void saveToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog SaveFD1 = new SaveFileDialog(); //string Sd_file = ""; SaveFD1.FileName = ""; SaveFD1.InitialDirectory = "C"; SaveFD1.Title = "save file Name"; SaveFD1.Filter= "JPG|.jpg|Bmp|.bmp"; if (SaveFD1.ShowDialog() != DialogResult.Cancel) { System.IO.Stream filename = (System.IO.FileStream)SaveFD1.OpenFile(); if (SaveFD1.Filter == "JPG") pictureBox1.Image.Save(SaveFD1.FileName); //pictureBox1.Image.Save (filename, System.Drawing.Imaging.ImageFormat.Jpeg); else if (SaveFD1.Filter == "Bmp") { //pictureBox1.Image.Save(filename, System.Drawing.Imaging.ImageFormat.Bmp); } filename.Close(); } }

    Read the article

  • Using Queries with Coherence Read-Through Caches

    - by jpurdy
    Applications that rely on partial caches of databases, and use read-through to maintain those caches, have some trade-offs if queries are required. Coherence does not support push-down queries, so queries will apply only to data that currently exists in the cache. This is technically consistent with "read committed" semantics, but the potential absence of data may make the results so unintuitive as to be useless for most use cases (depending on how much of the database is held in cache). Alternatively, the application itself may manually "push down" queries to the database, either retrieving results equivalent to querying the cache directly, or may query the database for a key set and read the values from the cache (relying on read-through to handle any missing values). Obviously, if the result set is too large, reading through the cache may cause significant thrashing. It's also worth pointing out that if the cache is asynchronously synchronized with the database (perhaps via database change listener), that an application may commit a transaction to the database, then generate a key set from the database via a query, then read cache entries through the cache, possibly resulting in a race condition where the application sees older data than it had previously committed. In theory this is not problematic but in practice it is very unintuitive. For this reason it often makes sense to invalidate the cache when updating the database, forcing the next read-through to update the cache.

    Read the article

  • Solutions for "Maintenance Mode"

    - by Ka Lyse
    Given a web application running across 10+ servers, what techniques have you put in place for doing things like altering the state of your website so that you can implement certain features. For instance, you might want to: Restrict Logins/Disable Certain Features Turn Site to "Read Only" Turn Site to Single "Maintenance Mode" page. Doing any of the above is pretty trivial. You can throw a particular "flag" in an .ini file, or add a row/value to a site_options table in your database and just read that value and do the appropriate thing. But these solutions have their problems. Disadvantages/Problems For instance, if you use a file for your application, and you want to switch off a certain feature temporarily, then you need to update this file on all servers. So then you might want to look at running something like ZooKeeper, but you are probably overcomplicating things. So then, you might decide that you want to store these "feature" flags in a database. But then you are obviously adding unncessary queries to each page request. So you think to yourself, that you will throw memcached in to the mix and just cache the query. Then you just retrieve all of your "Features" from memcached and add a 2ms~ latency to your application on every page. So to get around this, you decide to use a two tier-cache system, whereby you use an inmemory cache on each machine, (like Apc/Redis etc). This would work, but then it gets complicated, because you would have to set the key/hash life to perhaps 60 seconds, so that when you purge/invalidate the memcached object storing your "Features" result, your on machine cache is prompt enough to get the the new states. What suggestions might you have? Keeping in mind that optimization/efficiency is the priority here.

    Read the article

  • ????????????3?????

    - by Feng
    ?? ??blog?????oracle????????????,??????????????,??????: ?????????. ???????: ??????????,????????; ????????????,?” ???”??. 1. OS swapping/paging ??????concurrency??????? Oracle?????????, ??latch/mutex???????”?”,??????????????/???(????????????,??????????????????). ????OS??????swapping/paging????,???????????,??latch/mutex???????,????????????hung/slow???. ??swapping/paging??????: a). ???? b). ??????; ?????, ?????????????? c). ?????/????? ????????????????? ???????: Lock SGA, ??SGA(???latch/mutex)???pin???????swapping???. ???SGA??????,????large page(hugepage)??,??latch/mutex??/?????. 2. SGA resizing?????????? ?AMM/ASMM??????????, shared pool?buffer cache?????component????????????,??ora-4031???.??????????,???????resize????????????(?latch/mutex?????)?????, ?????????latch/mutex??. ????shared pool?resize??????,??latch/mutex???????. ?????????:  ?????bug; ???????????,??resize???????????????,???????????. ??bug?fix??????????impact, ???????????. ???????: 1). ??buffer cache?shared pool??(???????????,?????????) 2). ??resize???????16?? alter system set "_memory_broker_stat_interval"=999; Disable AMM/ASMM?????????,?????: ??ora-4031????????????. 3. DDL?????????? ??????????????????. ???????????DDL (??grant, ?????, ????????),???????????SQL?????invalidate?;????????SQL????????????,?????????hard parse ? SQL??????. ??????? “hardparse storm”, latch/mutex????????, ??library cache lock/row cache lock????; ??????????slow/hung. ???????: ???????????DDL ??????????,???????????,?? “????????????3?????"?

    Read the article

  • Load and Web Performance Testing using Visual Studio Ultimate 2010-Part 3

    - by Tarun Arora
    Welcome back once again, in Part 1 of Load and Web Performance Testing using Visual Studio 2010 I talked about why Performance Testing the application is important, the test tools available in Visual Studio Ultimate 2010 and various test rig topologies, in Part 2 of Load and Web Performance Testing using Visual Studio 2010 I discussed the details of web performance & load tests as well as why it’s important to follow a goal based pattern while performance testing your application. In part 3 I’ll be discussing Test Result Analysis, Test Result Drill through, Test Report Generation, Test Run Comparison, Asp.net Profiler and some closing thoughts. Test Results – I see some creepy worms! In Part 2 we put together a web performance test and a load test, lets run the test to see load test to see how the Web site responds to the load simulation. While the load test is running you will be able to see close to real time analysis in the Load Test Analyser window. You can use the Load Test Analyser to conduct load test analysis in three ways: Monitor a running load test - A condensed set of the performance counter data is maintained in memory. To prevent the results memory requirements from growing unbounded, up to 200 samples for each performance counter are maintained. This includes 100 evenly spaced samples that span the current elapsed time of the run and the most recent 100 samples.         After the load test run is completed - The test controller spools all collected performance counter data to a database while the test is running. Additional data, such as timing details and error details, is loaded into the database when the test completes. The performance data for a completed test is loaded from the database and analysed by the Load Test Analyser. Below you can see a screen shot of the summary view, this provides key results in a format that is compact and easy to read. You can also print the load test summary, this is generated after the test has completed or been stopped.         Analyse the load test results of a previously run load test – We’ll see this in the section where i discuss comparison between two test runs. The performance counters can be plotted on the graphs. You also have the option to highlight a selected part of the test and view details, drill down to the user activity chart where you can hover over to see more details of the test run.   Generate Report => Test Run Comparisons The level of reports you can generate using the Load Test Analyser is astonishing. You have the option to create excel reports and conduct side by side analysis of two test results or to track trend analysis. The tools also allows you to export the graph data either to MS Excel or to a CSV file. You can view the ASP.NET profiler report to conduct further analysis as well. View Data and Diagnostic Attachments opens the Choose Diagnostic Data Adapter Attachment dialog box to select an adapter to analyse the result type. For example, you can select an IntelliTrace adapter, click OK and open the IntelliTrace summary for the test agent that was used in the load test.   Compare results This creates a set of reports that compares the data from two load test results using tables and bar charts. I have taken these screen shots from the MSDN documentation, I would highly recommend exploring the wealth of knowledge available on MSDN. Leaving Thoughts While load testing the application with an excessive load for a longer duration of time, i managed to bring the IIS to its knees by piling up a huge queue of requests waiting to be processed. This clearly means that the IIS had run out of threads as all the threads were busy processing existing request, one easy way of fixing this is by increasing the default number of allocated threads, but this might escalate the problem. The better suggestion is to try and drill down to the actual root cause of the problem. When ever the garbage collection runs it stops processing any pages so all requests that come in during that period are queued up, but realistically the garbage collection completes in fraction of a a second. To understand this better lets look at the .net heap, it is divided into large heap and small heap, anything greater than 85kB in size will be allocated to the Large object heap, the Large object heap is non compacting and remember large objects are expensive to move around, so if you are allocating something in the large object heap, make sure that you really need it! The small object heap on the other hand is divided into generations, so all objects that are supposed to be short-lived are suppose to live in Gen-0 and the long living objects eventually move to Gen-2 as garbage collection goes through.  As you can see in the picture below all < 85 KB size objects are first assigned to Gen-0, when Gen-0 fills up and a new object comes in and finds Gen-0 full, the garbage collection process is started, the process checks for all the dead objects and assigns them as the valid candidate for deletion to free up memory and promotes all the remaining objects in Gen-0 to Gen-1. So in the future when ever you clean up Gen-1 you have to clean up Gen-0 as well. When you fill up Gen – 0 again, all of Gen – 1 dead objects are drenched and rest are moved to Gen-2 and Gen-0 objects are moved to Gen-1 to free up Gen-0, but by this time your Garbage collection process has started to take much more time than it usually takes. Now as I mentioned earlier when garbage collection is being run all page requests that come in during that period are queued up. Does this explain why possibly page requests are getting queued up, apart from this it could also be the case that you are waiting for a long running database process to complete.      Lets explore the heap a bit more… What is really a case of crisis is when the objects are living long enough to make it to Gen-2 and then dying, this is definitely a high cost operation. But sometimes you need objects in memory, for example when you cache data you hold on to the objects because you need to use them right across the user session, which is acceptable. But if you wanted to see what extreme caching can do to your server then write a simple application that chucks in a lot of data in cache, run a load test over it for about 10-15 minutes, forcing a lot of data in memory causing the heap to run out of memory. If you get to such a state where you start running out of memory the IIS as a mode of recovery restarts the worker process. It is great way to free up all your memory in the heap but this would clear the cache. The problem with this is if the customer had 10 items in their shopping basket and that data was stored in the application cache, the user basket will now be empty forcing them either to get frustrated and go to a competitor website or if the customer is really patient, give it another try! How can you address this, well two ways of addressing this; 1. Workaround – A x86 bit processor only allows a maximum of 4GB of RAM, this means the machine effectively has around 3.4 GB of RAM available, the OS needs about 1.5 GB of RAM to run efficiently, the IIS and .net framework also need their share of memory, leaving you a heap of around 800 MB to play with. Because Team builds by default build your application in ‘Compile as any mode’ it means the application is build such that it will run in x86 bit mode if run on a x86 bit processor and run in a x64 bit mode if run on a x64 but processor. The problem with this is not all applications are really x64 bit compatible specially if you are using com objects or external libraries. So, as a quick win if you compiled your application in x86 bit mode by changing the compile as any selection to compile as x86 in the team build, you will be able to run your application on a x64 bit machine in x86 bit mode (WOW – By running Windows on Windows) and what that means is, you could use 8GB+ worth of RAM, if you take away everything else your application will roughly get a heap size of at least 4 GB to play with, which is immense. If you need a heap size of more than 4 GB you have either build a software for NASA or there is something fundamentally wrong in your application. 2. Solution – Now that you have put a workaround in place the IIS will not restart the worker process that regularly, which means you can take a breather and start working to get to the root cause of this memory leak. But this begs a question “How do I Identify possible memory leaks in my application?” Well i won’t say that there is one single tool that can tell you where the memory leak is, but trust me, ‘Performance Profiling’ is a great start point, it definitely gets you started in the right direction, let’s have a look at how. Performance Wizard - Start the Performance Wizard and select Instrumentation, this lets you measure function call counts and timings. Before running the performance session right click the performance session settings and chose properties from the context menu to bring up the Performance session properties page and as shown in the screen shot below, check the check boxes in the group ‘.NET memory profiling collection’ namely ‘Collect .NET object allocation information’ and ‘Also collect the .NET Object lifetime information’.    Now if you fire off the profiling session on your pages you will notice that the results allows you to view ‘Object Lifetime’ which shows you the number of objects that made it to Gen-0, Gen-1, Gen-2, Large heap, etc. Another great feature about the profile is that if your application has > 5% cases where objects die right after making to the Gen-2 storage a threshold alert is generated to alert you. Since you have the option to also view the most expensive methods and by capturing the IntelliTrace data you can drill in to narrow down to the line of code that is the root cause of the problem. Well now that we have seen how crucial memory management is and how easy Visual Studio Ultimate 2010 makes it for us to identify and reproduce the problem with the best of breed tools in the product. Caching One of the main ways to improve performance is Caching. Which basically means you tell the web server that instead of going to the database for each request you keep the data in the webserver and when the user asks for it you serve it from the webserver itself. BUT that can have consequences! Let’s look at some code, trust me caching code is not very intuitive, I define a cache key for almost all searches made through the common search page and cache the results. The approach works fine, first time i get the data from the database and second time data is served from the cache, significant performance improvement, EXCEPT when two users try to do the same operation and run into each other. But it is easy to handle this by adding the lock as you can see in the snippet below. So, as long as a user comes in and finds that the cache is empty, the user locks and starts to get the cache no more concurrency issues. But lets say you are processing 10 requests per second, by the time i have locked the operation to get the results from the database, 9 other users came in and found that the cache key is null so after i have come out and populated the cache they will still go in to get the results again. The application will still be faster because the next set of 10 users and so on would continue to get data from the cache. BUT if we added another null check after locking to build the cache and before actual call to the db then the 9 users who follow me would not make the extra trip to the database at all and that would really increase the performance, but didn’t i say that the code won’t be very intuitive, may be you should leave a comment you don’t want another developer to come in and think what a fresher why is he checking for the cache key null twice !!! The downside of caching is, you are storing the data outside of the database and the data could be wrong because the updates applied to the database would make the data cached at the web server out of sync. So, how do you invalidate the cache? Well if you only had one way of updating the data lets say only one entry point to the data update you can write some logic to say that every time new data is entered set the cache object to null. But this approach will not work as soon as you have several ways of feeding data to the system or your system is scaled out across a farm of web servers. The perfect solution to this is Micro Caching which means you cache the query for a set time duration and invalidate the cache after that set duration. The advantage is every time the user queries for that data with in the time span for which you have cached the results there are no calls made to the database and the data is served right from the server which makes the response immensely quick. Now figuring out the appropriate time span for which you micro cache the query results really depends on the application. Lets say your website gets 10 requests per second, if you retain the cache results for even 1 minute you will have immense performance gains. You would reduce 90% hits to the database for searching. Ever wondered why when you go to e-bookers.com or xpedia.com or yatra.com to book a flight and you click on the book button because the fare seems too exciting and you get an error message telling you that the fare is not valid any more. Yes, exactly => That is a cache failure! These travel sites or price compare engines are not going to hit the database every time you hit the compare button instead the results will be served from the cache, because the query results are micro cached, its a perfect trade-off, by micro caching the results the site gains 100% performance benefits but every once in a while annoys a customer because the fare has expired. But the trade off works in the favour of these sites as they are still able to process up to 30+ page requests per second which means cater to the site traffic by may be losing 1 customer every once in a while to a competitor who is also using a similar caching technique what are the odds that the user will not come back to their site sooner or later? Recap   Resources Below are some Key resource you might like to review. I would highly recommend the documentation, walkthroughs and videos available on MSDN. You can always make use of Fiddler to debug Web Performance Tests. Some community test extensions and plug ins available on Codeplex might also be of interest to you. The Road Ahead Thank you for taking the time out and reading this blog post, you may also want to read Part I and Part II if you haven’t so far. If you enjoyed the post, remember to subscribe to http://feeds.feedburner.com/TarunArora. Questions/Feedback/Suggestions, etc please leave a comment. Next ‘Load Testing in the cloud’, I’ll be working on exploring the possibilities of running Test controller/Agents in the Cloud. See you on the other side! Thank You!   Share this post : CodeProject

    Read the article

  • Android ListView with alternate color and on focus color

    - by Yogesh
    I need to set alternate color in list view rows but when i do that it removes/ disables the on focus default yellow background I tried with backgroundColor rowView.setBackgroundColor(SOME COLOR); also with backgrounddrwable. rowView.setBackgroundColor(R.drawable.view_odd_row_bg); <!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. --> <item android:state_focused="true" android:state_enabled="false" android:state_pressed="true" android:drawable="@color/highlight" /> <item android:state_focused="true" android:state_enabled="false" android:drawable="@color/highlight" /> <item android:state_focused="true" android:state_pressed="true" android:drawable="@color/highlight" /> <item android:state_focused="false" android:state_pressed="true" android:drawable="@color/highlight" /> <item android:state_focused="true" android:drawable="@color/highlight" /> but it wont work. is there any way we can set background color and on focus color simultaneously which will work.

    Read the article

  • How to avoid "Page Expired" messages on logout with Wicket after redirect

    - by John
    Hi there. I'm taking my first steps in to the world of Wicket. I've set up a login form and a logout page. The logout page looks like this: public class LogoutPage extends WebPage { public LogoutPage(final PageParameters pageParams) { getSession().invalidate(); setResponsePage(getApplication().getHomePage()); } } When a user clicks the Logout link they're redirected to the homepage, so far so good. The problem is that when a user tries to click on any of the navigatable Link's they get a "Page Expired" message. I'd like to log the user out gracefully and allow the user to continue to browse the website without receiving the "Page Expired" message. Any help is greatly appreciated. By the way, I've tried to follow the Wicket examples but they seem to be using org.apache.wicket.authentication and I haven't figured out how to make this available to my project (I'm using eclipse and maven2).

    Read the article

  • Modifying ChangeSet in RIA Services

    - by Mohit
    Hi, I am using RIA Services Beta 2 with Linq2Sql and SL3. In my SL3, I have a datagrid where I can do some mappings of data (Updates, Inserts and Deletes). I override the Submit method when SubmitChanges() is called. In the submit method in the domain service, I do some validation. If a validation fails for a particular ChangeSetEntry in the ChangeSet, a ValidationErrors is added. Then I call the base.Submit(changeSet). So, if the changeset has 3 entities and one of the entities results in validation error, the other 2 entities are also rolled back. It looks like, RIA Services does an implicit transaction and hence it either submits all 3 or none even if 2 out of 3 does not have any validation error. Is there a way for the RIA service, to prevent rollback of the valid entities and only invalidate the ones that has validation failed. Inputs will be appreciated. Thanks Mohit

    Read the article

  • Random Gui errors using C# Mono on OSX

    - by Erik Karlsson
    Hello. Im developing a app in c# (winforms), which uses mono to run on osx. It contains some dynamic controls, for example a custom groupbox which contains some labels and textboxes, a button etc. these boxes can both be added and removed dynamically. Problem arises both when they are created, and removed, or even when a messagebox is shown. What happens is that sometimes on rendering white boxes appears, or some labels are not drawn correctly. And sometimes when a messagebox appears, it first opens up like 5 dummies which are just blank, and which you cant close. Am i doing something wrong, should i sleep the gui thread a bit after each creation, or should i invalidate stuff on my own? Or should i try GTK#? Many thanks on input on this, Erik

    Read the article

  • Android Map Performance poor because of many Overlays?

    - by Dave
    Hi, I have a map in my android application that shows many markers (~20-50). But the app performs very poor when i try to scroll/zoom (in Google Android Maps i did a sample search for pizza and there were also some 20-50 results found and i didn't notice any particular performance problems when zooming/scrolling through the map). Here is my (pseudo)code: onCreate() { .... drawable = this.getResources().getDrawable(R.drawable.marker1); itemizedOverlay = new MyItemizedOverlay(drawable,mapView); ... callWebServiceToRetrieveData(); createMarkers(); } createMarkers(){ for(elem:bigList){ GeoPoint geoPoint = new GeoPoint((int)(elem.getLat()*1000000), (int) (elem.getLon()*1000000)); OverlayItem overlayItem = new OverlayItem(geoPoint, elem.getName(), elem.getData()); itemizedOverlay.addOverlay(overlayItem); mapOverlays.add(itemizedOverlay); } mapView.invalidate(); } the MyItemizedOverlay.addOverlay looks like this: public void addOverlay(OverlayItem overlay) { m_overlays.add(overlay); populate(); }

    Read the article

  • iPhone: NSTimer Countdown (Display Minutes:Seconds)

    - by user298261
    Hello! I have my timer code set up, and it's all kosher, but I want my label to display "Minutes : seconds" instead of just seconds. -(void)countDown{ time -= 1; theTimer.text = [NSString stringWithFormat:@"%i", time]; if(time == 0) { [countDownTimer invalidate]; } } I've already set "time" to 600, or 10 minutes. However, I want the display to show 10:59, 10:58, etc. until it reaches zero. How do I do this? Thanks!

    Read the article

  • COMET with [Session ] TimeOut

    - by Amitd
    hi guys, Just Wondering how [Session] timeouts are(or can be) implemented when using Comet? I'm using Long polling Comet solution and want to implement a kind of Timeout feature. Example : If the user is on a Comet enabled page and doesn't respond to server events/notification for a period of time say 10 mins then invalidate his session and remove his request from server and redirect the user to a timeout page? Will this require Javascript XHR requests to check for a timeout explictly? Using ASP.NET 3.5 / C# (Doesn't need to be language specific) Thanks

    Read the article

  • Invalidating ASP.NET FormsAuthentication server side

    - by Rob Walker
    I am experimenting with FormsAuthentication (using ASP.NET MVC2) and it is working fairly well. However, one case I can't work out how to deal with is validating the user identity on the server to ensure it is still valid from the server's perspective. eg. User logs in ... gets a cookie/ticket Out of band the user is deleted on the server side User makes a new request to the server. HttpContext.User.Identity.Name is set to the deleted user. I can detect this fine, but what is the correct way to handle it? Calling FormsAuthentication.SignOut in the OnAuthorization on OnActionExecuting events is too late to affect the current request. Alternatively I would like to be able to calls FormsAuthentication.InvalidateUser(...) when the user is deleted (or database recreated) to invalidate all tickets for a given (or all) users. But I can't find an API to do this.

    Read the article

  • Resetting or refreshing a database connection

    - by cdonner
    This Android application on Google uses the following method to refresh the database after replacing the database file with a backup: public void resetDbConnection() { this.cleanup(); this.db = SQLiteDatabase.openDatabase( "/data/data/com.totsp.bookworm/databases/bookworm.db", null, SQLiteDatabase.OPEN_READWRITE); } I did not build this app, and I am not sure what happens. I am trying to make this idea work in my own application, but the data appears to be cached by the views, and the app continues to show data from the database that was replaced, even after I call cleanup() and reopen the database. I have to terminate and restart the activity in order to see the new data. I tried to call invalidate on my TabHost view, which pretty much contains everything. I thought that the views would redraw and refresh their underlying data, but this did also not have the expected result. I ended up restarting the activity programmatically, which works, but this seems to be a drastic measure. Is there a better way?

    Read the article

  • Changing a Container while using Visitor

    - by Florian
    Hi everyone, I implemented the Visitor pattern in C++ using a STL-like iterator for storing the Visitor's current position in the container. Now I would like to change the container while I iterate over it, and I'm especially interested in deleting items from the container, even the one I'm currently visiting. Now obviously this will invalidate the Visitors internal iterator, because it was pointing to exactly this item. Currently, I store a list of all iterators in the container and update them, as soon as anything is added to or removed from the list. So in a way this is similar to the Observer pattern applied to the iterator (as Observer) and the list (as Observable). Alternatively I considered having the visitor() methods return some hint to the Visitor about what happend to the current item and how to proceed iterating, but that doesn't sound like such a good idea either, because the visit() implementation shouldn't really care about finding the next item. So, my question is: What's the best way to keep a visitor working, even when items are added to the container or removed from it. Regards, Florian

    Read the article

  • good documentation about "avoid catching throwable", in context of weblogic server

    - by Marcel
    hi all, i am currently refactoring an existing codebase (EJBs...) to rip out all blocks where a Throwable is catched inside of the EJB. try { ... do some business logic } catch(Throwable t){ ... log and swallow ... :-( } i want/need to convince the people around me with proper documentation that "catching throwable" is a no-go for an EJB (we have lots of discussions around this :-(( ). weblogic will handle all the "Error" conditions and maybe invalidate EJBs and put fresh(working) EJBs into the pool. catching Throwable would undermine all these security nets provided by weblogic. and catching throwable is bad practice anyway (but people here are reluctant and use the "throwable" hammer everywhere). is anyone able to point me to some online docs where this behaviour is explained (for weblogic or jboss or...). i searched via google and had a look at the weblogic docs but wasn't able to find anything, just generic java doc. any help highly appreciated cheers marcel

    Read the article

  • Spring Weblfow 2 - Double Submit

    - by John W.
    Hello All, I am investigating a possible issue with double submits and I am looking at the possibilty of a double submit from a webflow execution. I have read many times that webflow will handle double submits, there are plenty references here. However I then came across I a forum response on the spring source forums contradicting what I read saying, SWF synchronizes on the conversation. Only one request will be processed at a time per conversation. Take note that if you're using snapshots, then it's possible repeatedly clicking on the submit button will generate a second request. I would recommend setting history to invalidate or discard in the transition from your view-state. We do have snapshots enabled but the book notes that using snapshots actually allows to solve the double submits. Does anyone have any insight on this? Thanks.

    Read the article

  • How to use NSObject to URLs with three20 properly

    - by Frank
    Basically i map my controllers to accept the address class to be passed into the listingpage controller. Which is done here: [map from:@"tt://listingPage/(initWithResult:)" toViewController:[ListingPageController class]]; [map from:[Address class] name:@"result" toURL:@"tt://listingPage/(initWithResult:)"]; This url is being used in my table item which I am has been invoked here: for (Address *result in [(id<SearchResultsModel>)self.model results]) { NSString* url = [result URLValueWithName:@"result"]; TTTableImageItem* tii = [TTTableMessageItem itemWithTitle:[result addressText] caption:[result addressText] text:[result subText] imageURL:[result image] URL:url]; [self.items addObject:tii]; } My app crashes, I am not sure why, seems to be getting an invalidate view. any help would be much appreciated.

    Read the article

  • How to cache queries in Rails across multiple requests

    - by m.u.sheikh
    I want to cache query results so that the same results are fetched "for more than one request" till i invalidate the cache. For instance, I want to render a sidebar which has all the pages of a book, much like the index of a book. As i want to show it on every page of the book, I have to load it on every request. I can cache the rendered sidebar index using action caching, but i also want to actually cache the the query results which are used to generate the html for the sidebar. Does Rails provide a way to do it? How can i do it?

    Read the article

  • How can I find which process has opened a specific file?

    - by Hosam Aly
    How can I find which processes have a specific file opened, and their open, access and share modes? Additionally, is it possible to change these values for a process? Or is it even possible to open a file for reading if it is already opened for exclusive access by another process? Please note that I don't want to invalidate the handle of the process having the file opened. I just want to be able to access the file (if possible). (I'm mainly asking about Windows, but solutions for other platforms are welcome, since they contribute to the community's knowledge.) Edit: I found some answers for my first question here and there. Edit 2: Thanks everybody for the tools you mentioned, but I am mainly looking for programmatical techniques (e.g. using Win32 APIs).

    Read the article

  • Why can final object be modified?

    - by Matt McCormick
    I came across the following code in a code base I am working on: public final class ConfigurationService { private static final ConfigurationService INSTANCE = new ConfigurationService(); private List providers; private ConfigurationService() { providers = new ArrayList(); } public static void addProvider(ConfigurationProvider provider) { INSTANCE.providers.add(provider); } ... INSTANCE is declared as final. Why can objects be added to INSTANCE? Shouldn't that invalidate the use of final. (It doesn't). I'm assuming the answer has to do something with pointers and memory but would like to know for sure.

    Read the article

  • Java - Google App Engine - InvalidClassException when I change a class that was stored in session sc

    - by Spines
    I updated my User class, and now whenever someone that had the old version of the User class stored in their session scope accesses my site, I get an InvalidClassException. javax.servlet.ServletException: java.lang.RuntimeException: java.io.InvalidClassException: User; local class incompatible: stream classdesc serialVersionUID = 4949038118012519093, local class serialVersionUID = -971500502189813151 How do I stop this error from happening for those users? I could probably invalidate everyone's sessions every time I want to update a class that gets stored in session scope, but is there a better way, so that my user's don't have to login again?

    Read the article

  • Help repaiting a Component

    - by serhio
    I am working with Microsoft.VisualBasic.PowerPacks.RectangleShape, but the question is common for components or controls in general. I added to a TextRectangleShape : RectangleShape a Text property: Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) MyBase.OnPaint(e) Dim f As Font = Me.Font Dim g As Graphics = e.Graphics Dim textRect As Rectangle = New Rectangle(Me.Location, Me.Size) Using br As New SolidBrush(Me._TextColor) g.DrawString(_Text, f, br, textRect) End Using End Sub Now when I move this control the text does not disappear from the former location. Maybe I could invalidate each time the Parent in the OnPaint, but if this is not a good solution if the parent has a time consuming repaint logic or I have a lot of my custom component moving at the same time. How do I properly repaint the component?

    Read the article

  • code for TouchPad works, but not for DPAD ...please help me to fix this..

    - by Chandan
    package org.coe.twoD; import android.app.Activity; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; //import android.graphics.Path; import android.graphics.Rect; //import android.graphics.RectF; import android.os.Bundle; //import android.util.Log; import android.util.Log; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; public class TwoD extends Activity implements OnClickListener { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); View draw2d = findViewById(R.id.draw_button); draw2d.setOnClickListener(this); } public void onClick(View v) { if (R.id.draw_button == v.getId()) { setContentView(new draw2D(this)); } } public class draw2D extends View { private static final String TAG = "Sudoku"; private float width; // width of one tile private float height; // height of one tile private int selX; // X index of selection private int selY; // Y index of selection private final Rect selRect = new Rect(); public draw2D(Context context) { super(context); } @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { width = w / 9f; height = h / 9f; getRect(selX, selY, selRect); Log.d(TAG, "onSizeChanged: width " + width + ", height " + height); super.onSizeChanged(w, h, oldw, oldh); } @Override protected void onDraw(Canvas canvas) { // Draw the background... Paint background = new Paint(); background.setColor(getResources().getColor(R.color.background)); canvas.drawRect(0, 0, getWidth(), getHeight(), background); // Draw the board... // Define colors for the grid lines Paint dark = new Paint(); dark.setColor(getResources().getColor(R.color.dark)); Paint hilite = new Paint(); hilite.setColor(getResources().getColor(R.color.hilite)); Paint light = new Paint(); light.setColor(getResources().getColor(R.color.light)); // Draw the minor grid lines for (int i = 0; i < 9; i++) { canvas.drawLine(0, i * height, getWidth(), i * height, light); canvas.drawLine(0, i * height + 1, getWidth(), i * height + 1, hilite); canvas.drawLine(i * width, 0, i * width, getHeight(), light); canvas.drawLine(i * width + 1, 0, i * width + 1, getHeight(), hilite); } // Draw the major grid lines for (int i = 0; i < 9; i++) { if (i % 3 != 0) continue; canvas.drawLine(0, i * height, getWidth(), i * height, dark); canvas.drawLine(0, i * height + 1, getWidth(), i * height + 1, hilite); canvas.drawLine(i * width, 0, i * width, getHeight(), dark); canvas.drawLine(i * width + 1, 0, i * width + 1, getHeight(), hilite); } /* * dark.setColor(Color.MAGENTA); Path circle= new Path(); * circle.addCircle(150, 150, 100, Path.Direction.CW); * canvas.drawPath(circle, dark); * * * Path rect=new Path(); * * RectF rectf= new RectF(150,200,250,300); rect.addRect(rectf, * Path.Direction.CW); canvas.drawPath(rect, dark); * * * canvas.drawRect(0, 0,250, 250, dark); * * * canvas.drawText("Hello", 200,200, dark); */ Paint selected = new Paint(); selected.setColor(Color.GREEN); canvas.drawRect(selRect, selected); } /* * public boolean onTouchEvent(MotionEvent event){ * if(event.getAction()!=MotionEvent.ACTION_DOWN) return * super.onTouchEvent(event); * select((int)(event.getX()/width),(int)(event.getY()/height)); * * * return true; } */ private void select(int x, int y) { invalidate(selRect); selX = Math.min(Math.max(x, 0), 8); selY = Math.min(Math.max(y, 0), 8); getRect(selX, selY, selRect); invalidate(selRect); } @Override public boolean onKeyUp(int keyCode, KeyEvent event) { return super.onKeyUp(keyCode, event); } @Override public boolean onTouchEvent(MotionEvent event) { if (event.getAction() != MotionEvent.ACTION_DOWN) return super.onTouchEvent(event); select((int) (event.getX() / width), (int) (event.getY() / height)); // game.showKeypadOrError(selX, selY); Log.d(TAG, "onTouchEvent: x " + selX + ", y " + selY); return true; } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { Log.d(TAG, "onKeyDown: keycode=" + keyCode + ", event=" + event); switch (keyCode) { case KeyEvent.KEYCODE_DPAD_UP: select(selX, selY - 1); break; case KeyEvent.KEYCODE_DPAD_DOWN: select(selX, selY + 1); break; case KeyEvent.KEYCODE_DPAD_LEFT: select(selX - 1, selY); break; case KeyEvent.KEYCODE_DPAD_RIGHT: select(selX + 1, selY); break; default: return super.onKeyDown(keyCode, event); } return true; } private void getRect(int x, int y, Rect rect) { rect.set((int) (x * width), (int) (y * height), (int) (x * width + width), (int) (y * height + height)); } } }

    Read the article

  • Which thread invokes SensorEventListener.onSensorChanged

    - by Christoph Heindl
    From my records it seems that SensorEventListener.onSensorChanged callback is called by the same thread that registered the callback. I.e there must be some message-queue synchronization going on in the background which allows the activitys UI-Thread to handle the callbacks. That leads to my question: Is there a need to synchronize SensorEventListener.onSensorChanged with the activitys UI-thread, assuming that the activitys UI-thread registered the SensorEventListener? I cannot find any documentation references, but can see various examples calling invalidate() unsychronized or synchronize the entire callback. I used something along the lines of Log.i(TAG, "" + Thread.currentThread().getId()); to retrieve threading information. I'm running android 2.1 update1. Best regards, Christoph

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >