Daily Archives

Articles indexed Tuesday November 12 2013

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

  • How to update off screen bitmap in a surfaceview thread

    - by DKDiveDude
    I have a Surfaceview thread and an off canvas texture bitmap that is being generated (changed), first row (line), every frame and then copied one position (line) down on regular surfaceview bitmap to make a scrolling effect, and I then continue to draw other things on top of that. Well that is what I really want, however I can't get it to work even though I am creating a separate canvas for off screen bitmap. It is just not scrolling at all. I other words I have a memory bitmap, same size as Surfaceview canvas, which I need to scroll (shift) down one line every frame, and then replace top line with new random texture, and then draw that on regular Surfaceview canvas. Here is what I thought would work; My surfaceChanged where I specify bitmap and canvasses and start thread: @Override public void surfaceCreated(SurfaceHolder holder) { intSurfaceWidth = mSurfaceView.getWidth(); intSurfaceHeight = mSurfaceView.getHeight(); memBitmap = Bitmap.createBitmap(intSurfaceWidth, intSurfaceHeight, Bitmap.Config.ARGB_8888); memCanvas = new Canvas(memCanvas); myThread = new MyThread(holder, this); myThread.setRunning(true); blnPause = false; myThread.start(); } My thread, only showing essential middle running part: @Override public void run() { while (running) { c = null; try { // Lock canvas for drawing c = myHolder.lockCanvas(null); synchronized (mSurfaceHolder) { // First draw off screen bitmap to off screen canvas one line down memCanvas.drawBitmap(memBitmap, 0, 1, null); // Create random one line(row) texture bitmap memTexture = Bitmap.createBitmap(imgTexture, 0, rnd.nextInt(intTextureImageHeight), intSurfaceWidth, 1); // Now add this texture bitmap to top of off screen canvas and hopefully bitmap memCanvas.drawBitmap(textureBitmap, intSurfaceWidth, 0, null); // Draw above updated off screen bitmap to regular canvas, at least I thought it would update (save changes) shifting down and add the texture line to off screen bitmap the off screen canvas was pointing to. c.drawBitmap(memBitmap, 0, 0, null); // Other drawing to canvas comes here } finally { // do this in a finally so that if an exception is thrown // during the above, we don't leave the Surface in an // inconsistent state if (c != null) { myHolder.unlockCanvasAndPost(c); } } } } For my game Tunnel Run. Right now I have a working solution where I instead have an array of bitmaps, size of surface height, that I populate with my random texture and then shift down in a loop for each frame. I get 50 frames per second, but I think I can do better by instead scrolling bitmap.

    Read the article

  • Is there a simple way to stop enemies standing in the same spot?

    - by Iain
    So: top-down game, my enemies chase the player, when they get within a certain distance they stand still and fire. If they're all coming from the same direction they all end up standing in the same spot (i.e. standing "within" each other), as I'm not currently doing collision detection between enemies - they are free to pass over each other. What's a simple way around this? Either some form of collision detection or some ai?

    Read the article

  • Axis2 issue with comment in WSDL

    - by Sirs
    I'm using an Axis2 client to access an external Webservice, whose WSDL starts with the following content: <?xml version="1.0" encoding="UTF-8"?><!--Created by TIBCO WSDL--><wsdl:definitions xmlns:wsdl=... My call to sendReceive crashes with the following error: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character 'C' (code 67) in prolog; expected '<' The 'C' is the first character on the comment in the WSDL. Without that comment everything works fine, but as far as my knowledge of basic XML dictates that comment is correct. My question would be: Is this a bug in Axis2 or is the accessed WSDL malformed? Is there any way to prevent Axis2 from crashing under these circumstances?

    Read the article

  • Scala importing a file in all files of a package

    - by Core_Dumped
    I need to use an implicit ordering that has been defined in an object in a file abc in the following way: object abc{ implicit def localTimeOrdering: Ordering[LocalDate] = Ordering.fromLessThan(_.isBefore(_)) } So, I make a package object xyz inside a file 'package.scala' that in turn is in the package 'xyz' that has files in which I need the implicit ordering to be applicable. I write something like this: package object xyz{ import abc._ } It does not seem to work. If I manually write the implicit definition statement inside the package object, it works perfectly. What is the correct way to import the object (abc) such that all of its objects/classes/definitions can be used in my entire package 'xyz' ?

    Read the article

  • SQL Replication (subsciber) can't connect to publication

    - by a3code
    I have 2 Virtual Machines, One with MS SQL server 2008 R2, other with MS SQL Server 2012 Express.... On 1 I have configuration for replication (publication), and I would like to setup Express version like subscriber. but I can't to connect to publisher SQL Server replication requires the actual server name to make a connection to the server. Specify the actual server name, 'XXXX'. (Replication.Utilities) I have tried to cheat and added XXXX server name to hosts file, but it dos't help. Additianlly I used to run http://www.hagrin.com/332/fixing-sql-server-replication-requires-actual-server-name-make-connection-server-error action for setup publication in correct way What I need to do for successful connection ?

    Read the article

  • Wrong code coverage on of unit test

    - by KamilPyc
    I'm using code coverage for unit tests in Xcode. Everything is working except some special cases, for example protocol declaration shows wrong values. If I have : @protocol SomeProtocole <NSObject> @property (nonatomic, readonly) NSObject *example; @end I will get 0% code coverage for this file. But I have unit test that is using class that conforms to that protocol. Only solution I found so far is to filter code coverage raport to not include protocols. But I would like to see real values for protocols. Any one have some solution to fix it?

    Read the article

  • Change asp message box header / title

    - by Jb Meris
    how can i change the title of my message box here is my code behind: string myStringVariable1 = string.Empty; myStringVariable1 = "Policy Number:" + " " + txtPolNo.Text.ToString() + " " + "with Issuance office:" + " " + dropIssOff.Text.ToString() + " " + "was not found on the database. Please make sure that your inputs are correct."; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + myStringVariable1 + "');", true);

    Read the article

  • Colorbox class don't work with ajax/dom object

    - by almal
    i usually use colorbox tool for open "popup windows" in my page and all are fine. In my new project the situation is little different because i use js/ajax/dom for create dinamically my objects in handleRequestStateChange() function. After import js,jquery and css for colorbox, in the head of my js page i write: $(document).ready(function () { $(window).scroll(function () { //oP1 = document.createTextNode(posizione_menu.offsetTop); //divIpt.appendChild(oMtx1); $(".divHcss").css("position", "fixed").css("top", "0px").css("z-index", "999"); }); //Examples of how to assign the Colorbox event to elements $(".group1").colorbox({rel:'group1'}); $(".group2").colorbox({rel:'group2', transition:"fade"}); $(".group3").colorbox({rel:'group3', transition:"none", width:"75%", height:"75%"}); $(".group4").colorbox({rel:'group4', slideshow:true}); $(".ajax").colorbox(); $(".youtube").colorbox({iframe:true, innerWidth:640, innerHeight:390}); $(".vimeo").colorbox({iframe:true, innerWidth:500, innerHeight:409}); $(".iframe").colorbox({iframe:true, width:"80%", height:"80%"}); $(".inline").colorbox({inline:true, width:"50%"}); $(".callbacks").colorbox({ onOpen:function(){ alert('onOpen: colorbox is about to open'); }, onLoad:function(){ alert('onLoad: colorbox has started to load the targeted content'); }, onComplete:function(){ alert('onComplete: colorbox has displayed the loaded content'); }, onCleanup:function(){ alert('onCleanup: colorbox has begun the close process'); }, onClosed:function(){ alert('onClosed: colorbox has completely closed'); } }); $('.non-retina').colorbox({rel:'group5', transition:'none'}) $('.retina').colorbox({rel:'group5', transition:'none', retinaImage:true, retinaUrl:true}); //Example of preserving a JavaScript event for inline calls. $("#click").click(function(){ $('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here."); return false; }); }); and after in handleRequestStateChange() i create my a element and assign to a div: var a = createElement('a'); //a.style.display = "block"; a.setAttribute('class','iframe'); a.setAttribute('href',"php/whois.php?P1="+oStxt.value); var divIp3 = createElement('div', 'divIp3', 'divIp3css'); var divIp31 = createElement('div', 'divIp31', 'divIp31css'); divIp3.appendChild(divIp31); divIp3.appendChild(a); a.appendChild(divIp31); The divIp31 become linkable but the href open page in a normal browser tab and not using attribute class for colorbox. Someone have an idea about? Thanks in advance AM

    Read the article

  • Unable to add a trac repository to mylyn in eclipse

    - by user592748
    Trac is running on a server on port 8002. With tunneling, I am able to access Trac on my machine using localhost:8002. I am able to login, create tickets using my browser. I want to integrate this trac project with Mylyn in Eclipse. I have installed mylyn with the Trac connector. I try adding task repositories in eclipse. I am able to successfully validate the settings, however, I am not able to add it as a task repository. Any help appreciated.

    Read the article

  • How to prevent users to change url parameter in PHP?

    - by Sachin
    I am developing a site where I am sending parameters like ids by url. I have used urlencode and base64encode to encode the parameters. My problem is that how can I prevent the users or hackers to play with url paramenters Or give access only if the parameter value is exist in database? I have at least 2 and at most 5 parameter in url so is this feasible to check every parameter is exist in database on every page? Thanks

    Read the article

  • What library to use to create a simple port scanner?

    - by durje
    I need advise to create a simple port-scanner, who will need to detect if some specific devices are connected to the network from theire IP/MAC address. I am working on windows 7 and can use preferably C++ Builder 2010 Embarcadero, or java or Qt. The library have to be under a public domain or equivalent, as my software is a proprietary software. What library would you advice? Do you know any free software that I could start from, or any examples? What about using Indy Sockets or Synapse TCP/IP Librarys? Thanks in advance.

    Read the article

  • Bitmap size exceeds VM budget after second load

    - by jonny
    This is driving me crazy. I have a game which has a bitmap as the background, this is big so I scale it down and this works fine. However when I navigate to another activity and then reload the game screen it crashes on drawing the background. I am calling recycle on all the bitmaps and setting them to null on onDestroy() but this doesn't help. Any ideas and if not how can I debug the memory to see at which step its growing. I looked at getting the heap but nothing of any size is on there really. Thanks.

    Read the article

  • why i'm permanently logged off my be

    - by Fixus
    Hello i have a problem with BE in my system. I'm permanently and automaticly logged out it after some time. 10-15 seconds, sometimes faster, sometimes slower. It's not connected with beeing idle cause I can be logged off even when I'm checking page tree or saving records I've set lock ip on 1 but it didn't help. The problem is most common under Firefox or Chome, what is strange under internet explorer i don't see it as often Other strange thing is that I see it on my live version but when I'm working on my local copy it doen not occure TYPO3 version 4.6.4

    Read the article

  • loop is cut one element of the array

    - by Walaa
    The problem is : Write a program that reads a number n and then declares an array of n elements. The program then fills the array with the first n numbers, where each number is two to the power of the previous. Finally, display array’s contents. My code : import java.util.*; public class Q1 { static Scanner scan = new Scanner (System.in); public static void main(String args [] ) { int num; int i = 0; System.out.println("Enter a number :"); num = scan.nextInt(); double [] a=new double[num]; a[0]= num ; for ( ;i<=a.length-1 ; i++) { a[i+1] = Math.pow(2,a[i]); System.out.println((int)(a[i]) ); } } } The error is : ----jGRASP exec: java Q1 Enter a number : 4 4 16 65536 Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4 at Q1.main(Q1.java:16) ----jGRASP wedge2: exit code for process is 1. why it says that? And the number by user printed twice!

    Read the article

  • Round time to 5 minute nearest SQL Server

    - by Drako
    i don't know if it can be usefull to somebody but I went crazy looking for a solution and ended up doing it myself. Here is a function that (according to a date passed as parameter), returns the same date and approximate time to the nearest multiple of 5. It is a slow query, so if anyone has a better solution, it is welcome. A greeting. CREATE FUNCTION [dbo].[RoundTime] (@Time DATETIME) RETURNS DATETIME AS BEGIN DECLARE @min nvarchar(50) DECLARE @val int DECLARE @hour int DECLARE @temp int DECLARE @day datetime DECLARE @date datetime SET @date = CONVERT(DATETIME, @Time, 120) SET @day = (select DATEADD(dd, 0, DATEDIFF(dd, 0, @date))) SET @hour = (select datepart(hour,@date)) SET @min = (select datepart(minute,@date)) IF LEN(@min) > 1 BEGIN SET @val = CAST(substring(@min, 2, 1) as int) END else BEGIN SET @val = CAST(substring(@min, 1, 1) as int) END IF @val <= 2 BEGIN SET @val = CAST(CAST(@min as int) - @val as int) END else BEGIN IF (@val <> 5) BEGIN SET @temp = 5 - CAST(@min%5 as int) SET @val = CAST(CAST(@min as int) + @temp as int) END IF (@val = 60) BEGIN SET @val = 0 SET @hour = @hour + 1 END IF (@hour = 24) BEGIN SET @day = DATEADD(day,1,@day) SET @hour = 0 SET @min = 0 END END RETURN CONVERT(datetime, CAST(DATEPART(YYYY, @day) as nvarchar) + '-' + CAST(DATEPART(MM, @day) as nvarchar) + '-' + CAST(DATEPART(dd, @day) as nvarchar) + ' ' + CAST(@hour as nvarchar) + ':' + CAST(@val as nvarchar), 120) END

    Read the article

  • Get Url Parameters In Django

    - by picomon
    I want to get current transaction id in url. it should be like this www.example.com/final_result/53432e1dd34b3 . I wrote the below codes, but after successful payment, I'm redirected to Page 404. (www.example.com/final_result//) Views.py @csrf_exempt def pay_notif(request, v_transaction_id): if request.method=='POST': v_transaction_id=request.POST.get('transaction_id') endpoint='https://testpay.com/?v_transaction_id={0}&type=json' req=endpoint.format(v_transaction_id) last_result=urlopen(req).read() if 'Approved' in last_result: session=Pay.objects.filter(session=request.session.session_key).latest('id') else: return HttpResponse(status=204) return render_to_response('final.html',{'session':session},context_instance=RequestContext(request)) Urls.py url(r'^final_result/(?P<v_transaction_id>[-A-Za-z0-9_]+)/$', 'digiapp.views.pay_notif', name="pay_notif"), Template: <input type='hidden' name='v_merchant_id' value='{{newpayy.v_merchant_id}}' /> <input type='hidden' name='item_1' value='{{ newpayy.esell.up_name }}' /> <input type='hidden' name='description_1' value='{{ newpayy.esell.up_description }}' /> <input type='hidden' name='price_1' value='{{ newpayy.esell.up_price }}' /> #page to be redirected to after successful payment <input type='hidden' name='success_url' value='http://127.0.0.1:8000/final_result/{{newpayy.v_transaction_id}}/' /> How can I go about this?

    Read the article

  • pass an ID with hyperlik but cant get this ID value from a fk in one table when i click in insert

    - by susan
    Something strange happened in my codes, actually I have a hyperlink that pass ID value in a query string to second page.in second page i have 2 sql datasource that both these sql datasources should get this id value and pass it to a filter parameter to show sth in datalist. so in another word I have a first page that has an hyperlink read ID value from a datasource and pass it to second page.its like below: <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "~/forumpage.aspx?ID="+Eval("ID")%>'><%#Eval("title")%> </asp:HyperLink> then in second page i have one sql datasource with a query like this ...where ID=@id and get this id in query string from db.it work great . but i have problem with second sql datasource in second page it has a query sth like below:...forms.question_id=@id then in sql reference both to query string as ID that get by first page in hyperlink. but when i click in insert button show me error with fk. error:Error:The INSERT statement conflicted with the FOREIGN KEY constraint "FK_forumreply_forumquestions". The conflict occurred in database "forum", table "dbo.forumquestions", column 'ID'. The statement has been terminated. my tables (question(ID,user_id(fk),Cat_id(fk),title,bodytext) (reply(ID,userr_id(fk),questionn_id(fk),titlereply,bodytestreply); When by hand in cb i gave a number in questionn_id like 1 it show me successful but when it want read from a filter by datasource this field face with problem. plzzzz help i really need skip from this part.and cause i am new i guess I cant understand the logic way clearly. <asp:SqlDataSource ID="sdsreply" runat="server" ConnectionString="<%$ ConnectionStrings:forumConnectionString %>" SelectCommand="SELECT forumreply.ID, forumreply.userr_id, forumreply.questionn_id, forumreply.bodytextreply, forumreply.datetimereply, forumquestions.ID AS Expr1, forumusers.ID AS Expr2, forumusers.username FROM forumquestions INNER JOIN forumreply ON forumquestions.ID = forumreply.questionn_id INNER JOIN forumusers ON forumquestions.user_id = forumusers.ID AND forumreply.userr_id = forumusers.ID where forumreply.questionn_id=@questionn_id"> <SelectParameters> <asp:QueryStringParameter Name="questionn_id" QueryStringField="ID" /> </SelectParameters> </asp:SqlDataSource> it is cb for second page in insert button: { if (Session["userid"] != null) { lblreply.Text = Session["userid"].ToString(); } else { Session["userid"]=null; } if (HttpContext.Current.User.Identity.IsAuthenticated) { lblshow.Text = string.Empty; string d = HttpContext.Current.User.Identity.Name; lblshow.Text =d + "???? ??? ?????." ; foreach (DataListItem item in DataList2.Items) { Label questionn_idLabel = (Label)item.FindControl("questionn_idLabel"); Label userr_idLabel = (Label)item.FindControl("userr_idLabel"); lbltest.Text = string.Empty; lbltest.Text = questionn_idLabel.Text; lblreply.Text = string.Empty; lblreply.Text = userr_idLabel.Text; } } else { lblshow.Text = "??? ??? ??? ??? ?? ?? ?????? ???? ???? ???? ????? ??? ??? ? ??? ????? ???????."; } } { if(HttpContext.Current.User.Identity.IsAuthenticated) { if (Page.IsValid) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["forumConnectionString"].ConnectionString); try { con.Open(); SqlCommand cmd = new SqlCommand("insert into forumreply (userr_id,questionn_id,bodytextreply,datetimereply)values(@userr_id,@questionn_id,@bodytextreply,@datetimereply)", con); cmd.Parameters.AddWithValue("userr_id",lblreply.Text); cmd.Parameters.AddWithValue("questionn_id",lbltest.Text); cmd.Parameters.AddWithValue("bodytextreply",txtbody.Text); cmd.Parameters.AddWithValue("datetimereply",DateTime.Now ); cmd.ExecuteNonQuery(); } catch (Exception exp) { Response.Write("<b>Error:</b>"); Response.Write(exp.Message); } finally { con.Close(); } lblmsg.Text = "???? ??? ?? ?????? ??? ?????.thx"; lblshow.Visible = false; //lbltxt.Text = txtbody.Text; txtbody.Text = string.Empty; } } else { lblmsg.Text = string.Empty; Session["rem"] = Request.UrlReferrer.AbsoluteUri; Response.Redirect("~/login.aspx"); } }

    Read the article

  • To return the list in JSON format

    - by Reshma
    Below is my code, List<string> modified_listofstrings = new List<string>(); string sJSON = ""; System.Web.Script.Serialization.JavaScriptSerializer jSearializer = new System.Web.Script.Serialization.JavaScriptSerializer(); resulted_value = final_resulted_series_name + ":" + period_name + ":" + period_final_value; modified_listofstrings.Add(resulted_value); json_resultedvalue = JsonConvert.SerializeObject(resulted_value); modified_listofstrings.Add(json_resultedvalue); sJSON = jSearializer.Serialize(modified_listofstrings); return sJSON; But on following line , sJSON = jSearializer.Serialize(modified_listofstrings); I am getting an error as Cannot implicitly convert type string to system.collection.generic.list

    Read the article

  • HTML5 video tag with multiple bitrate videos?

    - by Joanne
    I have MP4 video files encoding at different bitrate to be compatible for both iOS on Wifi and Edge connection. I would like to have them progressive loaded form my website using HTML5 video tag. video_big.mp4 encoded for iOS on Wifi H.264 Baseline, 25fps, 640x480, 500kbps video_small.mp4 encoded for iOS on Edge/3G H.264 Baseline, 25fps, 320x240, 56kbps My question is: How can I write the HTML5 video tag to serve video_big.mp4 to iOS devices that connected through Wifi, and serve video_small.mp4 to iOS devices that connected through Edge/3G? I'm running on PHP/Apache server. Thank you :)

    Read the article

  • Camera Filters in ios7

    - by Muhannad Dasoqie
    How I can use the camera filters that already exist in iOS7? If i used this code: UIImagePickerController *picker= [[UIImagePickerController alloc]init]; picker.delegate = self; picker.allowsEditing = YES; picker.sourceType = UIImagePickerControllerSourceTypeCamera; [self presentModalViewController:picker animated:YES]; the camera will open, and I can capture a photo but without using the filters. my question is: can I use the exist filters in camera view in iOS7?

    Read the article

  • ZF2 Vertical Form

    - by yunhasnawa
    I created a simple form in typical ZF2 application. The form class code is just a modified code provided by Zend's Album example. <?php namespace Admin\Form; use Zend\Form\Form; class CityForm extends Form { public function __construct($name = null) { parent::__construct('city'); $this->setAttribute('method', 'post'); $this->add(array( 'name' => 'id', 'attributes' => array( 'type' => 'hidden', ), )); $this->add(array( 'name' => 'name', 'attributes' => array( 'type' => 'text' ), 'options' => array( 'label' => 'Name', ), )); $this->add(array( 'name' => 'province', 'attributes' => array( 'type' => 'text' ), 'options' => array( 'label' => 'Province', ), )); $this->add(array( 'name' => 'country', 'attributes' => array( 'type' => 'text' ), 'options' => array( 'label' => 'Country', ), )); $this->add(array( 'name' => 'coordinate', 'attributes' => array( 'type' => 'text' ), 'options' => array( 'label' => 'Coordinate', ), )); $this->add(array( 'name' => 'submit', 'attributes' => array( 'type' => 'submit', 'value' => 'Save', 'id' => 'submitButton', ), )); } } And call it like this in CityController, a typical controller extends AbstractActionController: public function addAction() { $form = new CityForm(); $viewData = array( 'form' => $form ); return new ViewModel($viewData); } Finally in view I echo it like this: <?php $title = 'Add New City'; ?> <?php $this->headtitle($title); ?> <h1><?php echo $this->escapehtml($title); ?></h1> <?php $form = $this->form; ?> <?php $form->setAttribute('action', $this->url('city', array('action' => 'add'))); ?> <?php $form->prepare(); ?> <?php echo $this->form()->openTag($form); echo $this->formHidden($form->get('id')); echo $this->formRow($form->get('name')); echo $this->formRow($form->get('province')); echo $this->formRow($form->get('country')); echo $this->formRow($form->get('coordinate')); echo $this->formSubmit($form->get('submit')); echo $this->form()->closeTag(); ?> What I expected to see is a vertical form like this: But what i got is an ugly form like this: What's wrong with my code? Please help. EDIT: When I inspect element, the form generated is strange. The <input> element is inside the <label> element. <form id="city" name="city" method="post" action="/karciscus/public/admin/city/add"> <input type="hidden" value="" name="id"> <label> <span>Name</span><input type="text" value="" name="name"> </label> <label> <span>Province</span><input type="text" value="" name="province"> </label> <label> <span>Country</span><input type="text" value="" name="country"> </label> <label> <span> Coordinate</span><input type="text" value="" name="coordinate"> </label> <input type="submit" value="Save" id="submitButton" name="submit"> </form> I'm pretty sure it is the cause of my ugly rendered form. I think it is not supposedly like that. How to fix it?

    Read the article

  • Improving performance on data pasting 2000 rows with validations

    - by Lohit
    I have N rows (which could be nothing less than 1000) on an excel spreadsheet. And in this sheet our project has 150 columns like this: Now, our application needs data to be copied (using normal Ctrl+C) and pasted (using Ctrl+V) from the excel file sheet on our GUI sheet. Copy pasting 1000 records takes around 5-6 seconds which is okay for our requirement, but the problem is when we need to make sure the data entered is valid. So we have to validate data in each row generate appropriate error messages and format the data as per requirement. So we need to at runtime parse and evaluate data in each row. Now all the formatting of data and validations come from the back-end database and we have it in a data-table (dtValidateAndFormatConditions). The conditions would be around 50. So you can see how slow this whole process becomes since N X 150 X 50 operations are required to complete this whole process. Initially it took approximately 2-3 minutes but now i have reduced it to 20 - 30 seconds. However i have increased the speed by making an expression parser of my own - and not by any algorithm, is there any other way i can improve performance, by using Divide and Conquer or some other mechanism. Currently i am not really sure how to go about this. Here is what part of my code looks like: public virtual void ValidateAndFormatOnCopyPaste(DataTable DtCopied, int CurRow) { foreach (DataRow dRow in dtValidateAndFormatConditions.Rows) { string Condition = dRow["Condition"]; string FormatValue = Value = dRow["Value"]; GetValidatedFormattedData(DtCopied,ref Condition, ref FormatValue ,iRowIndex); Condition = Parse(Condition); dRow["Condition"] = Condition; FormatValue = Parse(FormatValue ); dRow["Value"] = FormatValue; } } The above code gets called row-wise like this: public override void ValidateAndFormat(DataTable dtChangedRecords, CellRange cr) { int iRowStart = cr.Row, iRowEnd = cr.Row + cr.RowCount; for (int iRow = iRowStart; iRow < iRowEnd; iRow++) { ValidateAndFormatOnCopyPaste(dtChangedRecords,iRow); } } Please know my question needs a more algorithmic solution than code optimization, however any answers containing code related optimizations will be appreciated as well. (Tagged Linq because although not seen i have been using linq in some parts of my code).

    Read the article

  • cannot read but can write on serial port through Android Emulator

    - by Aad
    I am working on a program that is communicating with serial port over USB through Android emulator. emulator -qemu -serial /dev/ttyUSB0 The emulator is able to open the port and write into it. However, read is not happening. The program has a timeout for read maintained by a timer. The read happens in a separate 'read' thread. The main thread has a socketpair fd pair to signal the read-thread that the serial port is closed post timeout. In the read-thread, polling happens(poll() function call) over the 2 file-descriptors: one is serial port fd, the other is one of the socketpair. The board that I have connected to works fine with sending commands over 'cutecom' The poll never succeeds for serial port. However, poll succeeds for 'socketpair'ed fd and the thread ends on a close-signal sent from main-thread post timeout. Ouestions: Are there any special settings for read as even loop-back fails Are there differences between settings for read and write on a serial port?

    Read the article

  • WCF timeout exception detailed investigation

    - by Jason Kealey
    We have an application that has a WCF service (*.svc) running on IIS7 and various clients querying the service. The server is running Win 2008 Server. The clients are running either Windows 2008 Server or Windows 2003 server. I am getting the following exception, which I have seen can in fact be related to a large number of potential WCF issues. System.TimeoutException: The request channel timed out while waiting for a reply after 00:00:59.9320000. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout. ---> System.TimeoutException: The HTTP request to 'http://www.domain.com/WebServices/myservice.svc/gzip' has exceeded the allotted timeout of 00:01:00. The time allotted to this operation may have been a portion of a longer timeout. I have increased the timeout to 30min and the error still occurred. This tells me that something else is at play, because the quantity of data could never take 30min to upload or download. The error comes and goes. At the moment, it is more frequent. It does not seem to matter if I have 3 clients running simultaneously or 100, it still occurs once in a while. Most of the time, there are no timeouts but I still get a few per hour. The error comes from any of the methods that are invoked. One of these methods does not have parameters and returns a bit of data. Another takes in lots of data as a parameter but executes asynchronously. The errors always originate from the client and never reference any code on the server in the stack trace. It always ends with: at System.Net.HttpWebRequest.GetResponse() at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) On the server: I've tried (and currently have) the following binding settings: maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" It does not seem to have an impact. I've tried (and currently have) the following throttling settings: <serviceThrottling maxConcurrentCalls="1500" maxConcurrentInstances="1500" maxConcurrentSessions="1500"/> It does not seem to have an impact. I currently have the following settings for the WCF service. [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Single)] I ran with ConcurrencyMode.Multiple for a while, and the error still occurred. I've tried restarting IIS, restarting my underlying SQL Server, restarting the machine. All of these don't seem to have an impact. I've tried disabling the Windows firewall. It does not seem to have an impact. On the client, I have these settings: maxReceivedMessageSize="2147483647" <system.net> <connectionManagement> <add address="*" maxconnection="16"/> </connectionManagement> </system.net> My client closes its connections: var client = new MyClient(); try { return client.GetConfigurationOptions(); } finally { client.Close(); } I have changed the registry settings to allow more outgoing connections: MaxConnectionsPerServer=24, MaxConnectionsPer1_0Server=32. I have now just recently tried SvcTraceViewer.exe. I managed to catch one exception on the client end. I see that its duration is 1 minute. Looking at the server side trace, I can see that the server is not aware of this exception. The maximum duration I can see is 10 seconds. I have looked at active database connections using exec sp_who on the server. I only have a few (2-3). I have looked at TCP connections from one client using TCPview. It usually is around 2-3 and I have seen up to 5 or 6. Simply put, I am stumped. I have tried everything I could find, and must be missing something very simple that a WCF expert would be able to see. It is my gut feeling that something is blocking my clients at the low-level (TCP), before the server actually receives the message and/or that something is queuing the messages at the server level and never letting them process. If you have any performance counters I should look at, please let me know. (please indicate what values are bad, as some of these counters are hard to decypher). Also, how could I log the WCF message size? Finally, are there any tools our there that would allow me to test how many connections I can establish between my client and server (independently from my application) Thanks for your time! Extra information added June 20th: My WCF application does something similar to the following. while (true) { Step1GetConfigurationSettingsFromServerViaWCF(); // can change between calls Step2GetWorkUnitFromServerViaWCF(); DoWorkLocally(); // takes 5-15minutes. Step3SendBackResultsToServerViaWCF(); } Using WireShark, I did see that when the error occurs, I have a five TCP retransmissions followed by a TCP reset later on. My guess is the RST is coming from WCF killing the connection. The exception report I get is from Step3 timing out. I discovered this by looking at the tcp stream "tcp.stream eq 192". I then expanded my filter to "tcp.stream eq 192 and http and http.request.method eq POST" and saw 6 POSTs during this stream. This seemed odd, so I checked with another stream such as tcp.stream eq 100. I had three POSTs, which seems a bit more normal because I am doing three calls. However, I do close my connection after every WCF call, so I would have expected one call per stream (but I don't know much about TCP). Investigating a bit more, I dumped the http packet load to disk to look at what these six calls where. 1) Step3 2) Step1 3) Step2 4) Step3 - corrupted 5) Step1 6) Step2 My guess is two concurrent clients are using the same connection, that is why I saw duplicates. However, I still have a few more issues that I can't comprehend: a) Why is the packet corrupted? Random network fluke - maybe? The load is gzipped using this sample code: http://msdn.microsoft.com/en-us/library/ms751458.aspx - Could the code be buggy once in a while when used concurrently? I should test without the gzip library. b) Why would I see step 1 & step 2 running AFTER the corrupted operation timed out? It seems to me as if these operations should not have occurred. Maybe I am not looking at the right stream because my understanding of TCP is flawed. I have other streams that occur at the same time. I should investigate other streams - a quick glance at streams 190-194 show that the Step3 POST have proper payload data (not corrupted). Pushing me to look at the gzip library again.

    Read the article

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